c# - Theater Seating application in WPF -problems in databinding -


i new wpf, , want develop application theater seating in wpf- c#.net. did research lost not know how each seat's data (sold or not, price, in row) should bound field in table in sql express. should using observablecollection populate contents of datatable in it? also, should using grid of buttons? or rectangles? how should proceed if want front left , front right buttons inclined bit instead of being horizontal? should using wrappanel if want have 3 areas seats? left area, space alter, middle area, space alter , right area? if can give me hints me start, more glad. in advance...

you're asking lot of questions @ once, , impossible answer them without writing program you, i'll offer high-level approach take. you'll have spend time dig details. plenty of info on stackoverflow , otherwise on these details.

anyways-

database, 3 tables

seatstatus table

  • id, int, primary key
  • name, string (e.g. available, sold, broken)

pricepoint table

  • id, int, primary key
  • name, string (e.g. default, onsale, premium)
  • price, float (e.g. 10.0, 8.0, 12.0)

seat table

  • id, int, primary key
  • seatstatusid, int, foreign key -> seatstatus table
  • pricepointid, int, foreign key -> pricepoint table
  • row, int
  • column, int

application model

i use entity framework 4 , generate model theaterseating database. create seat objects automatically contain references seatstatus , pricepoint. slick.

edit 1

once you've created model have .edmx file represents data, , can read/write database easily. assuming file called theaterseatingmodel.edmx, auto-generated classes provide means call along lines of:

theaterseatingentities entities = new theaterseatingentities(); 

you have access entire database, including:

entities.seats entities.pricepoints 

etc.

you can use these classes naturally expect, example:

seat seat = new seat(); seat.row = 10; seat.column = 5; entities.seats.add(seat); entities.savechanges(); 

populate observablecollection these seats inside class, , set view's (the xaml control's) datacontext class.

public observablecollection<seat> seatcollection {get;set;}  public viewmodelconstructor() {    theaterseatingentities entities = new theaterseatingentities();    seatcollection = new observablecollection<seat>(entities.seats); } 

this populate collection seat objects.

a simple wpf binding collection along lines of:

<listbox itemssource={binding seatcollection} /> 

ui

if me use wpf itemscontrol itemssource set observablecollection of seats. place itemscontrol inside of canvas. itemscontrol's itemscontrol.itemtemplate control each seat in view. can bind itemtemplates canvas.left , canvas.top seat.row , seat.column place seats in appropriate positions on screen. can make template button, rectangle, image of seat, anything. can set styles , triggers make seat display differently depending on pricepoint, seatstatus, etc.

i think wpf great project you're starting.

good luck!


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -