TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
hans
NA
4
3.7k
local Database with 2 tables and listbox selection transfer
Jun 22 2013 11:30 PM
hi, (sry for my english..) i read the complete "Windows Phone Mango Local Database:
http://www.geekchamp.com/articles/windows-phone-mango-local-database-mapping-and-database-operations" articel but my proplem dont solved.
i draw a picture to show what i want to programm but i dont find the funktion to upload . ok i want a 1:x conetion of events to dates but i can only shop x:x in the listbox by doppel clicking.
how this example :)
[code]
the main table 1
namespace Spielleiter_App_03
{
[Table]
public class Tabelle_Veranstaltung
{
private EntitySet<Tabelle_Termin> Tabelle_Termin_Ref;
public Tabelle_Veranstaltung()
{
this.Tabelle_Termin_Ref = new EntitySet<Tabelle_Termin>(this.On_Tabelle_Termin_Added, this.On_Tabelle_Termin_Removed);
}
private void On_Tabelle_Termin_Added(Tabelle_Termin tabelle_Termin)
{
tabelle_Termin.Tabelle_Veranstaltung = this;
}
private void On_Tabelle_Termin_Removed(Tabelle_Termin tabelle_Termin)
{
tabelle_Termin.Tabelle_Veranstaltung = null;
}
[Column(IsPrimaryKey = true, IsDbGenerated = true)]
public int Id
{
get;
set;
}
[Column(CanBeNull = true)]
public string Extra
{
get;
set;
}
[Column(CanBeNull = true)]
public string Name
{
get;
set;
}
[Column(CanBeNull = true)]
public string Typ
{
get;
set;
}
[Association(Name = "Veranstaltung_Termin", Storage = "Tabelle_Termin_Ref", ThisKey = "Id", OtherKey = "veranstaltungID")]
public EntitySet<Tabelle_Termin> termin
{
get
{
return this.Tabelle_Termin_Ref;
}
}
}
}
---------------------------------------------
the to x table
namespace Spielleiter_App_03
{
[Table]
public class Tabelle_Termin
{
private Nullable<int> VeranstaltungID;
private EntityRef<Tabelle_Veranstaltung> tabelle_VeranstaltungRef = new EntityRef<Tabelle_Veranstaltung>();
[Column(IsPrimaryKey = true, IsDbGenerated = true)]
public int Termin_ID
{
get;
set;
}
[Column(CanBeNull = true)]
public string Ort
{
get;
set;
}
[Column(CanBeNull = true)]
public string Datum
{
get;
set;
}
[Column(CanBeNull = true)]
public string Extra
{
get;
set;
}
[Column(CanBeNull = true)]
public string Uhrzeit
{
get;
set;
}
[Column(Storage = "VeranstaltungID", DbType = "Int")]
public int? veranstaltungID
{
get
{
return this.VeranstaltungID;
}
set
{
this.VeranstaltungID = value;
}
}
[Association(Name = "Veranstaltung_Termin", Storage = "tabelle_VeranstaltungRef", ThisKey = "veranstaltungID", OtherKey = "Id", IsForeignKey = true)]
public Tabelle_Veranstaltung Tabelle_Veranstaltung
{
get
{
return this.tabelle_VeranstaltungRef.Entity;
}
set
{
Tabelle_Veranstaltung previousValue = this.tabelle_VeranstaltungRef.Entity;
if (((previousValue != value) || (this.tabelle_VeranstaltungRef.HasLoadedOrAssignedValue == false)))
{
if ((previousValue != null))
{
this.tabelle_VeranstaltungRef.Entity = null;
previousValue.termin.Remove(this);
}
this.tabelle_VeranstaltungRef.Entity = value;
if ((value != null))
{
value.termin.Add(this);
this.VeranstaltungID = value.Id;
}
else
{
this.VeranstaltungID = default(Nullable<int>);
}
}
}
}
}
}
---------------------------
the get class
namespace Spielleiter_App_03
{
public class Hauptklasse : DataContext
{
public Hauptklasse(string connectionString) : base(connectionString)
{
}
public Table<Tabelle_Veranstaltung> Veranstaltungen_H
{
get
{
return this.GetTable<Tabelle_Veranstaltung>();
}
}
public Table<Tabelle_Termin> Termin_H
{
get
{
return this.GetTable<Tabelle_Termin>();
}
}
}
}
-------------------------------------
namespace Spielleiter_App_03
{
public partial class Erstellen_Uebersicht : PhoneApplicationPage
{
private const string strConnectionString = @"isostore:/StudentDB.sdf";
public string a;
public Erstellen_Uebersicht()
{
InitializeComponent();
using (Hauptklasse Empd = new Hauptklasse(strConnectionString))
{
if (!Empd.DatabaseExists())
{
Empd.CreateDatabase();
}
}
using (Hauptklasse Empd = new Hauptklasse(strConnectionString))
{
var a = from b in Empd.GetTable<Tabelle_Veranstaltung>() select b.Extra;
List<Tabelle_Veranstaltung> dataSource = new List<Tabelle_Veranstaltung>();
foreach (var x in a)
{
dataSource.Add(new Tabelle_Veranstaltung() { Extra = x });
}
this.listBox1.ItemsSource = dataSource;
listBox1.DisplayMemberPath = "Extra";
}
}
private void myButton_Einmalige_Veranstaltung_Erstellen_Click(object sender, RoutedEventArgs e)
{
this.NavigationService.Navigate(new Uri("/Erstellen_Button_Einmalige_Veranstaltung.xaml", UriKind.Relative));
}
private void button1_Click(object sender, RoutedEventArgs e)
{
}
private void listBox1_Loaded(object sender, System.Windows.RoutedEventArgs e)
{}
private void listBox1_Tap(object sender, GestureEventArgs e)
{
}
private void listBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
{}
private void listBox1_DoubleTap(object sender, GestureEventArgs e)
{
var listBoxItem = listBox1.ItemContainerGenerator.ContainerFromIndex(listBox1.SelectedIndex) as ListBoxItem;
NavigationService.Navigate(new Uri(string.Format("/Erstellen_Uebersicht_Auswahl_Einmalige_Veranstaltung.xaml?parameter={0}",listBoxItem.ToString(),"edit"), UriKind.Relative));
}
}
}
------------------------------------
the event greater site
namespace Spielleiter_App_03
{
public partial class Erstellen_Button_Einmalige_Veranstaltung : PhoneApplicationPage
{
private const string strConnectionString = @"isostore:/StudentDB.sdf";
public Erstellen_Button_Einmalige_Veranstaltung()
{
InitializeComponent();
using (Hauptklasse context = new Hauptklasse(strConnectionString))
{
if (!context.DatabaseExists())
{
context.CreateDatabase();
}
}
}
private void myButton_erstellen_Click(object sender, RoutedEventArgs e)
{
using (Hauptklasse Empd = new Hauptklasse(strConnectionString))
{
Tabelle_Veranstaltung newVeranstaltung = new Tabelle_Veranstaltung
{
Extra = myTextBox_Name.Text.ToString() + " - " + " einmalige Veranstaltung ",
Name = myTextBox_Name.Text.ToString(),
};
Empd.Veranstaltungen_H.InsertOnSubmit(newVeranstaltung);
Empd.SubmitChanges();
}
this.NavigationService.Navigate(new Uri("/Erstellen_Uebersicht.xaml", UriKind.Relative));
}
}
}
-------------------------------------------
the site if you dopple click of the event in the listbox
namespace Spielleiter_App_03
{
public partial class Erstellen_Uebersicht_Auswahl_Einmalige_Veranstaltung : PhoneApplicationPage
{
private const string strConnectionString = @"isostore:/StudentDB.sdf";
public Erstellen_Uebersicht_Auswahl_Einmalige_Veranstaltung()
{
InitializeComponent();
using (Hauptklasse Empd = new Hauptklasse(strConnectionString))
{
if (!Empd.DatabaseExists())
{
Empd.CreateDatabase();
}
}
using (Hauptklasse Empd = new Hauptklasse(strConnectionString))
{
var a = from b in Empd.GetTable<Tabelle_Termin>() select b.Extra;
List<Tabelle_Termin> dataSource = new List<Tabelle_Termin>();
foreach (var x in a)
{
dataSource.Add(new Tabelle_Termin() { Extra = x });
}
this.myListBox.ItemsSource = dataSource;
myListBox.DisplayMemberPath = "Extra";
}
}
private void myButton_Click(object sender, RoutedEventArgs e)
{
this.NavigationService.Navigate(new Uri("/Erstellen_Uebersicht_Auswahl_Button_Termin_hinzu_Einmalige_Veranstaltung.xaml", UriKind.Relative));
}
}
}
---------------------------
great a x date for your event
if you want the namespace Spielleiter_App_03
{
public partial class Erstellen_Uebersicht_Auswahl_Button_Termin_hinzu_Einmalige_Veranstaltung : PhoneApplicationPage
{
private const string strConnectionString = @"isostore:/StudentDB.sdf";
public Erstellen_Uebersicht_Auswahl_Button_Termin_hinzu_Einmalige_Veranstaltung()
{
InitializeComponent();
using (Hauptklasse context = new Hauptklasse(strConnectionString))
{
if (!context.DatabaseExists())
{
context.CreateDatabase();
}
}
}
private void myButton_Erstellen_Click(object sender, RoutedEventArgs e)
{
using (Hauptklasse Empd = new Hauptklasse(strConnectionString))
{
Tabelle_Termin newTermin = new Tabelle_Termin
{ Extra = mytextBox_Ort.Text.ToString() + " " + mytextBox_Datum.Text.ToString() + " " + mytextBox_Uhrzeit.Text.ToString(),
Ort = mytextBox_Ort.Text.ToString(),
Datum = mytextBox_Datum.Text.ToString(),
Uhrzeit = mytextBox_Uhrzeit.Text.ToString(),
};
Empd.Termin_H.InsertOnSubmit(newTermin);
Empd.SubmitChanges();
this.NavigationService.Navigate(new Uri("/Erstellen_Uebersicht_Auswahl_Einmalige_Veranstaltung.xaml", UriKind.Relative));
}
}
}
}
big thanks to ever help
Reply
Answers (
0
)
Car park fee
FileUpload Fails when trying to upload > 5MB files