Præsentation er lastning. Vent venligst

Præsentation er lastning. Vent venligst

MaxiBio Planlægning Eksempel på skærmbilleder med navigation og tilhørende kode.

Lignende præsentationer


Præsentationer af emnet: "MaxiBio Planlægning Eksempel på skærmbilleder med navigation og tilhørende kode."— Præsentationens transcript:

1 MaxiBio Planlægning Eksempel på skærmbilleder med navigation og tilhørende kode

2

3

4 private void btnTilBigrafForm_Click(object sender, EventArgs e) { BiografForm bioForm = new BiografForm(this.aktuelMaxiBio,null); bioForm.ShowDialog(); } public BiografForm(MaxiBio initMaxiBio, Biograf initBiograf) { InitializeComponent(); // opret test objekt //this.aktuelMaxiBio = new MaxiBio(); this.aktuelMaxiBio = initMaxiBio; this.aktuelBiograf = initBiograf; if (this.aktuelBiograf != null) { this.txtBiografnavn.Text = this.aktuelBiograf.Biografnavn; this.fyldBiografsalListBox(); } private void fyldBiografsalListBox() { Biografsal[] sale = this.aktuelBiograf.HentAlleBiografsale(); this.lbxBiografsale.Items.Clear(); this.lbxBiografsale.Items.AddRange(sale); }

5 private void lbxBiografer_SelectedIndexChanged(object sender, EventArgs e) { Biograf valgtBiograf = this.lbxBiografer.SelectedItem as Biograf; BiografForm bioForm = new BiografForm(this.aktuelMaxiBio, valgtBiograf); bioForm.ShowDialog(); this.fyldBiografListBox(); // fyld op igen, da data kan være ændret } public BiografForm(MaxiBio initMaxiBio, Biograf initBiograf) { InitializeComponent(); // opret test objekt //this.aktuelMaxiBio = new MaxiBio(); this.aktuelMaxiBio = initMaxiBio; this.aktuelBiograf = initBiograf; if (this.aktuelBiograf != null) { this.txtBiografnavn.Text = this.aktuelBiograf.Biografnavn; this.fyldBiografsalListBox(); } private void fyldBiografsalListBox() { Biografsal[] sale = this.aktuelBiograf.HentAlleBiografsale(); this.lbxBiografsale.Items.Clear(); this.lbxBiografsale.Items.AddRange(sale); }

6

7 private void lbxBiografsale_SelectedIndexChanged(object sender, EventArgs e) { Biografsal valgtSal = this.lbxBiografsale.SelectedItem as Biografsal; BioGrafSalForm salForm = new BioGrafSalForm(this.aktuelBiograf, valgtSal); salForm.ShowDialog(); fyldBiografsalListBox(); // da data kan være ændret fyldes op igen } public BioGrafSalForm(Biograf initBiograf, Biografsal initBiografsal) { InitializeComponent(); //this.aktuelBiograf = new Biograf("Test Biograf"); //this.txtBiografnavn.Text = this.aktuelBiograf.Biografnavn; this.aktuelBiograf = initBiograf; this.aktuelBiografsal = initBiografsal; if (this.aktuelBiograf != null) { // fyld data i gui this.txtBiografnavn.Text = this.aktuelBiograf.Biografnavn; } if (this.aktuelBiografsal != null) { this.txtSalnavn.Text = this.aktuelBiografsal.Navn; this.txtAntalpladser.Text = this.aktuelBiografsal.AntalPladser.ToString(); this.chkThx.Checked = this.aktuelBiografsal.Thx; this.fyldForestillingListBox(); } private void fyldForestillingListBox() { Forestilling[] alleForestillinger = this.aktuelBiografsal.HentAlleForestillinger(); this.lbxForestillinger.Items.Clear(); this.lbxForestillinger.Items.AddRange(alleForestillinger); }

8

9 private void lbxForestillinger_SelectedIndexChanged(object sender, EventArgs e) { Forestilling valgtForestilling = lbxForestillinger.SelectedItem as Forestilling; ForestillingForm foForm = new ForestillingForm(this.aktuelBiografsal, valgtForestilling); foForm.ShowDialog(); this.fyldForestillingListBox(); // data kan være ændret så vi fylder ind igen } public ForestillingForm(Biografsal initBiografsal, Forestilling initForestilling) { InitializeComponent(); this.aktuelBiografsal = initBiografsal; this.aktuelForestilling = initForestilling; this.txtSalnavn.Text = this.aktuelBiografsal.Navn; if (this.aktuelForestilling != null) { this.txtDato.Text = this.aktuelForestilling.Dato.ToString(); this.txtTidspunkt.Text = this.aktuelForestilling.Tidspunkt.ToString(); visDataForTilknyttetFilm(); } private void visDataForTilknyttetFilm() { Film tilknyttetFilm = this.aktuelForestilling.HentTillnyttetFilm(); if (tilknyttetFilm != null) { this.txtFilmTitel.Text = tilknyttetFilm.Titel; } else { this.txtFilmTitel.Text = "Ingen film tilknyttet"; }

10

11 private void btnTilFilmForm_Click(object sender, EventArgs e) { FilmForm fForm = new FilmForm(this.aktuelMaxiBio); fForm.ShowDialog(); } public FilmForm(MaxiBio initMaxibio) { InitializeComponent(); // opret test objekt //this.aktuelMaxibio = new MaxiBio(); this.aktuelMaxibio = initMaxibio; fyldFilmListBox(); } private void fyldFilmListBox() { // først hentes data Film[] alleFilm = this.aktuelMaxibio.HentAlleFilm(); // så indsættes i listboxen, der først "renses" for evt. gamle data this.lbxFilm.Items.Clear(); this.lbxFilm.Items.AddRange(alleFilm); }

12 FilmForm kan også skaffe sig adgang til MaxiBio objektet ved at tilgå MaxiBioFasade klassen, der har fat i objektet som et static objekt, der så ikke behøves at blive overført til formen.

13 private void btnTilFilmFormUdenMaxiBioObjekt_Click (object sender, EventArgs e) { // Her overføres MaxiBio objektet ikke som parameter // Da objektet ligger i MaxiBioFasade klassen som static // kan FilmForm skaffe sig objektet via MaxiBioFasade klassen FilmForm fForm = new FilmForm(); fForm.ShowDialog(); } public FilmForm() { InitializeComponent(); // opret test objekt //this.aktuelMaxibio = new MaxiBio(); // Da MaxiBioFasade "holder" på MaxiBio objektet kan vi få fat i det // selv her fra formen uden at det overføres til os this.aktuelMaxibio = MaxiBioFasade.GetMaxiBioObjektet(); fyldFilmListBox(); } private void fyldFilmListBox() { // først hentes data Film[] alleFilm = this.aktuelMaxibio.HentAlleFilm(); // så indsættes i listboxen, der først "renses" for evt. gamle data this.lbxFilm.Items.Clear(); this.lbxFilm.Items.AddRange(alleFilm); }

14 ForestillingForm kan også skaffe sig adgang til MaxiBio objektet ved at tilgå MaxiBioFasade klassen og via denne så få adgang til alle film. Der kan derved laves en liste af Film til udvælgelse.

15 private void lbxForestillinger_SelectedIndexChanged(object sender, EventArgs e) { Forestilling valgtForestilling = lbxForestillinger.SelectedItem as Forestilling; ForestillingForm foForm = new ForestillingForm(this.aktuelBiografsal, valgtForestilling); foForm.ShowDialog(); this.fyldForestillingListBox(); // data kan være ændret så vi fylder ind igen } public ForestillingForm(Biografsal initBiografsal, Forestilling initForestilling) { InitializeComponent(); this.aktuelBiografsal = initBiografsal; this.aktuelForestilling = initForestilling; this.txtSalnavn.Text = this.aktuelBiografsal.Navn; if (this.aktuelForestilling != null) { this.txtDato.Text = this.aktuelForestilling.Dato.ToString(); this.txtTidspunkt.Text = this.aktuelForestilling.Tidspunkt.ToString(); visDataForTilknyttetFilm(); } fyldFilmListBox(); } private void visDataForTilknyttetFilm() { Film tilknyttetFilm = this.aktuelForestilling.HentTillnyttetFilm(); if (tilknyttetFilm != null) { this.txtFilmTitel.Text = tilknyttetFilm.Titel; } else { this.txtFilmTitel.Text = "Ingen film tilknyttet"; } private void fyldFilmListBox() { MaxiBio aktueltMaxiBio = MaxiBioFasade.GetMaxiBioObjektet(); Film[] alleFilm = aktueltMaxiBio.HentAlleFilm(); this.lbxFilm.Items.Clear(); this.lbxFilm.Items.AddRange(alleFilm); }


Download ppt "MaxiBio Planlægning Eksempel på skærmbilleder med navigation og tilhørende kode."

Lignende præsentationer


Annoncer fra Google