赞
踩
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- using System.Xml;
- using MyCinema.Models;
-
- namespace MyCinema
- {
- public partial class MainForm : Form
- {
- Cinema cinema;
- Dictionary<string, Label> labels = new Dictionary<string, Label>();
- int ticket = 0;
- string key = null;
-
- public MainForm()
- {
- InitializeComponent();
- }
-
- private void MainForm_Load(object sender, EventArgs e)
- {
- this.lblActor.Text = "";
- this.lblDirector.Text = "";
- this.lblMovieName.Text = "";
- this.lblPrice.Text = "";
- this.lblTime.Text = "";
- this.lblType.Text = "";
- this.lblCalcPrice.Text = "";
- this.txtCustomer.Enabled = false;
- this.cmbDisCount.Enabled = false;
- this.rdoNormal.Checked = true;
-
- cinema = new Cinema();
- //放映厅座位(初始)
- InitSeats(7, 5, tpCinema);
-
-
- cinema.Load();
-
- }
-
-
- private void InitSeats(int seatRow,int seatLine,TabPage tb)
- {
- Label label;
- Seat seat;
- for (int i = 0; i < seatRow; i++)
- {
- for (int j = 0; j < seatLine; j++)
- {
- label = new Label();
-
- label.BackColor = Color.Yellow;
-
- label.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,((byte)(134)));
-
- label.AutoSize = false;
- label.Size = new System.Drawing.Size(50, 25);
-
- label.Text = (j + 1).ToString() + "-" + (i + 1).ToString();
- label.TextAlign = ContentAlignment.MiddleCenter;
-
- label.Location = new Point(60 + (i * 90), 60 + (j * 60));
-
- label.Click += new System.EventHandler(lblSeat_Click);
- tb.Controls.Add(label);
- labels.Add(label.Text, label);
-
- seat = new Seat((j + 1).ToString() + "-" + (i + 1).ToString(), Color.Yellow);
-
- cinema.Seats.Add(seat.SeatNum, seat);
- }
- }
- }
-
-
- private void tsmiMovies_Click(object sender, EventArgs e)
- {
- //放映列表是否为空
- if (cinema.Schedule.Items.Count == 0)
- {
- cinema.Schedule.LoadItems();
- }
- InitTreeView();
- }
-
- //获取最新播放列表
- private void tsmiNew_Click(object sender, EventArgs e)
- {
- cinema.Schedule.LoadItems();
- cinema.SoldTickets.Clear();
- InitTreeView();
- }
-
-
- private void InitTreeView()
- {
- tvMovies.BeginUpdate();
- tvMovies.Nodes.Clear();
-
- string movieName = null;
- TreeNode movieNode = null;
- foreach (ScheduleItem item in cinema.Schedule.Items.Values)
- {
- if (movieName != item.Movie.MovieName)
- {
- movieNode = new TreeNode(item.Movie.MovieName);
- tvMovies.Nodes.Add(movieNode);
- }
- TreeNode timeNode = new TreeNode(item.Time);
- movieNode.Nodes.Add(timeNode);
- movieName = item.Movie.MovieName;
-
- }
- tvMovies.EndUpdate();
- }
-
- private void tvMovies_AfterSelect(object sender, TreeViewEventArgs e)
- {
- TreeNode node = tvMovies.SelectedNode;
- if (node == null) return;
- if (node.Level != 1) return;
- key = node.Text;
- //将详细信息显示
- this.lblMovieName.Text = cinema.Schedule.Items[key].Movie.MovieName;
- this.lblDirector.Text = cinema.Schedule.Items[key].Movie.Director;
- this.lblActor.Text = cinema.Schedule.Items[key].Movie.Actor;
- this.lblPrice.Text = cinema.Schedule.Items[key].Movie.Price.ToString();
- this.lblTime.Text = cinema.Schedule.Items[key].Time;
- this.lblType.Text = cinema.Schedule.Items[key].Movie.MovieType.ToString();
- this.picMovie.Image = Image.FromFile(cinema.Schedule.Items[key].Movie.Poster);
- this.lblCalcPrice.Text = "";
-
- //清空座位
- ClearSeat();
- //遍历座位情况
- foreach (Ticket ticket in cinema.SoldTickets)
- {
- foreach (Seat seat in cinema.Seats.Values)
- {
- if ((ticket.ScheduleItem.Time == key)
- &&(ticket.Seat.SeatNum == seat.SeatNum))
- {
- seat.Color = Color.Red;
- }
- }
- }
- UpdateSeat();
- }
-
- //清空座位
- private void ClearSeat()
- {
- foreach (S
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。