資源簡介
數據存在文本中
public FrmCinema()
{
InitializeComponent();
}
Cinema cinema = new Cinema();
Label lbl = new Label();
//獲取新放映列表:
private void tsmiNew_Click(object sender, EventArgs e)
{
BingTreeView();
}
//選擇內容發生改變:
private void tvMovies_AfterSelect(object sender, TreeViewEventArgs e)
{
if (this.tvMovies.SelectedNode.Level == 1)
{
string time = this.tvMovies.SelectedNode.Text;
ScheduleItem item = cinema.Schedule.Items[time];
this.lblActor.Text = item.Movie.Actor;
this.lblDirector.Text = item.Movie.Director;
this.lblMovieName.Text = item.Movie.MovieName;
this.lblPrice.Text = item.Movie.Price.ToString();
this.lblTime.Text = item.Time;
this.lblType.Text = item.Movie.MovieType.ToString();
this.picMovie.Image = Image.FromFile(@"Image\" item.Movie.Poster);
this.lblCalcPrice.Text = item.Movie.Price.ToString();
//將所有座位設置為黃色
foreach (Seat var in cinema.Seats.Values)
{
var.Color = Color.Yellow;
}
//在已售出的票中循環判斷
foreach (Ticket ticket in cinema.SoldTickets)
{
foreach (Seat seat in this.cinema.Seats.Values)
{
//場次相同且座位號相同
if (ticket.ScheduleItem.Time == time && ticket.Seat.SeatNum == seat.SeatNum)
{
//更新座位顏色
seat.Color = Color.Red;
}
}
}
// 將座位顏色更新到Label上顯示
foreach (Seat seat in cinema.Seats.Values)
{
foreach (Label lbl in tpCinema.Controls)
{
// 座位號相同證明是對應Label
if (lbl.Text == seat.SeatNum)
{
lbl.BackColor = seat.Color;
}
}
}
}
}
//點擊普通票
private void rdoNormal_CheckedChanged(object sender, EventArgs e)
{
this.cmbDisCount.Enabled = false;
this.txtCustomer.Enabled = false;
this.lblCalcPrice.Text = lblPrice.Text;
}
//點擊贈票
private void rdoFree_CheckedChanged(object sender, EventArgs e)
{
this.txtCustomer.Enabled = true;
this.cmbDisCount.Enabled = false;
this.lblCalcPrice.Text = lblPrice.Text;
}
//點擊學生票
private void rdoStudent_CheckedChanged(object sender, EventArgs e)
{
if (this.lblPrice.Text != "")
{
this.cmbDisCount.Enabled = true;
this.txtCustomer.Enabled = false;
this.lblCalcPrice.Text = (Convert.ToDouble(this.lblPrice.Text) * Convert.ToDouble(this.cmbDisCount.Text) / 10).ToString();
}
}
//加載
private void FrmCinema_Load(object sender, EventArgs e)
{
this.rdoNormal.Checked = true;
this.cmbDisCount.SelectedIndex = 0;
InitSeats(5, 7);
}
//選擇折扣變化:
private void cmbDisCount_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.lblPrice.Text != "")
{
this.lblCalcPrice.Text = (Convert.ToDouble(this.lblPrice.Text) * Convert.ToDouble(this.cmbDisCount.Text) / 10).ToString();
}
}
/// <summary>
/// 獲取放映列表綁定到TreeView
/// </summary>
private void BingTreeView()
{
this.tvMovies.Nodes.Clear();
//加載XML
cinema.Schedule.LoadItems();
//綁定到TreeView
TreeNode root = null;
foreach (ScheduleItem var in cinema.Schedule.Items.Values)
{
if (root == null || root.Text != var.Movie.MovieName)
{
//根節點
root = new TreeNode(var.Movie.MovieName);
this.tvMovies.Nodes.Add(root);
}
//子節點
root.Nodes.Add(var.Time);
}
}
/// <summary>
/// 初始化座位
/// </summary>
private void InitSeats(int row, int col)
{
for (int i = 0; i < row; i )
{
for (int j = 0; j < col; j )
{
Label lb = new Label();
lb.BackColor = Color.Yellow;
lb.Location = new Point(20 j * 100, 50 i * 70);
lb.Font = new Font("Courier New", 11);
lb.Name = (i 1) "-" (j 1);
lb.Size = new Size(80, 30);
lb.TabIndex = 0;
lb.Text = (i 1) "-" (j 1);
lb.TextAlign = ContentAlignment.MiddleCenter;
lb.Click = lb_Click;
tpCinema.Controls.Add(lb);
//添加座位對象到CInema的Seats集合中
Seat seat = new Seat(lb.Text, Color.Yellow);
cinema.Seats.Add(seat.SeatNum, seat);
}
}
}
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.Linq;
using?System.Text;
using?System.Threading.Tasks;
using?System.Runtime.Serialization.Formatters.Binary;
using?System.IO;
namespace?青鳥影院
{
????[Serializable]
????///?
????///?電影院類
????///?
????public?class?Cinema
????{
????????public?Cinema()
????????{
????????????SoldTickets?=?new?List();
????????????Schedule?=?new?Schedule();
????????????Seats?=?new?Dictionary();
????????}
????????public?Schedule?Schedule?{?get;?set;?}
????????public?Dictionary?Seats?{?get;?set;?}
????????public?List?SoldTickets?{?get;?set;?}
????????///?
????????///?加載放映場次
????????///?
????????public?void?Load()
????????{
????????????using?(FileStream?fs?=?new?FileStream(“student.dat“FileMode.Open))
????????????{
????????????????BinaryFormatter?bf?=?new?BinaryFormatter();
????????????????this.SoldTickets?=?bf.Deserialize(fs)?as?List;
????????????}
????????}
????????///?
????????///?保存銷售信息
????????///?
????????public?void?Save()
????????{
????????????//
????????????using?(FileStream?fs?=?new?FileStream(“student.dat“FileMode.Create))
????????????{
????????????????BinaryFormatter?bf?=?new?BinaryFormatter();
????????????????bf.Serialize(fs?SoldTickets);
????????????}
????????}
????}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
????..A..H.?????57856??2020-12-26?10:02??影院電影售票系統?1.0\ByMovieDemo\.vs\青鳥影院\v15\.suo
?????文件????????187??2015-03-18?13:53??影院電影售票系統?1.0\ByMovieDemo\App.config
?????文件????????188??2015-03-22?11:09??影院電影售票系統?1.0\ByMovieDemo\bin\Debug\11-20?1-1.txt
?????文件????????188??2015-03-22?10:53??影院電影售票系統?1.0\ByMovieDemo\bin\Debug\11-20?1-2.txt
?????文件????????188??2015-03-22?11:02??影院電影售票系統?1.0\ByMovieDemo\bin\Debug\11-20?1-3.txt
?????文件????????186??2015-03-22?11:09??影院電影售票系統?1.0\ByMovieDemo\bin\Debug\13-00?1-1.txt
?????文件????????186??2015-04-27?16:47??影院電影售票系統?1.0\ByMovieDemo\bin\Debug\13-00?1-2.txt
?????文件????????186??2015-03-22?11:09??影院電影售票系統?1.0\ByMovieDemo\bin\Debug\13-00?5-7.txt
?????文件????????188??2015-04-27?17:02??影院電影售票系統?1.0\ByMovieDemo\bin\Debug\15-45?3-3.txt
?????文件????????185??2015-03-22?10:45??影院電影售票系統?1.0\ByMovieDemo\bin\Debug\17-30?1-2.txt
?????文件????????188??2015-03-22?10:45??影院電影售票系統?1.0\ByMovieDemo\bin\Debug\21-00?3-5.txt
?????文件????????188??2015-03-29?21:15??影院電影售票系統?1.0\ByMovieDemo\bin\Debug\23-10?1-2.txt
?????文件????????188??2015-03-29?21:15??影院電影售票系統?1.0\ByMovieDemo\bin\Debug\23-10?2-3.txt
?????文件????????185??2020-12-11?13:50??影院電影售票系統?1.0\ByMovieDemo\bin\Debug\9-00?1-1.txt
?????文件????????185??2015-03-22?10:56??影院電影售票系統?1.0\ByMovieDemo\bin\Debug\9-00?1-2.txt
?????文件????????185??2015-03-22?10:56??影院電影售票系統?1.0\ByMovieDemo\bin\Debug\9-00?2-3.txt
?????文件????????185??2015-03-22?10:56??影院電影售票系統?1.0\ByMovieDemo\bin\Debug\9-00?3-2.txt
?????文件???????1232??2015-03-18?16:37??影院電影售票系統?1.0\ByMovieDemo\bin\Debug\Data\ShowList.xm
?????文件?????128543??2013-07-29?15:03??影院電影售票系統?1.0\ByMovieDemo\bin\Debug\Image\不二神探.jpg
?????文件?????192484??2013-07-29?15:02??影院電影售票系統?1.0\ByMovieDemo\bin\Debug\Image\中國合伙人.jpg
?????文件??????57020??2013-07-29?15:00??影院電影售票系統?1.0\ByMovieDemo\bin\Debug\Image\西游降魔篇.jpg
?????文件?????153488??2013-07-29?15:00??影院電影售票系統?1.0\ByMovieDemo\bin\Debug\Image\鋼鐵俠3.jpg
?????文件???????1372??2020-12-11?13:50??影院電影售票系統?1.0\ByMovieDemo\bin\Debug\student.dat
?????文件??????30208??2020-12-26?10:00??影院電影售票系統?1.0\ByMovieDemo\bin\Debug\青鳥影院.exe
?????文件????????187??2015-03-18?13:53??影院電影售票系統?1.0\ByMovieDemo\bin\Debug\青鳥影院.exe.config
?????文件??????62976??2020-12-26?10:00??影院電影售票系統?1.0\ByMovieDemo\bin\Debug\青鳥影院.pdb
?????文件??????22984??2015-04-27?16:46??影院電影售票系統?1.0\ByMovieDemo\bin\Debug\青鳥影院.vshost.exe
?????文件????????187??2015-03-18?13:53??影院電影售票系統?1.0\ByMovieDemo\bin\Debug\青鳥影院.vshost.exe.config
?????文件????????490??2012-06-02?22:34??影院電影售票系統?1.0\ByMovieDemo\bin\Debug\青鳥影院.vshost.exe.manifest
?????文件???????1456??2015-03-22?11:08??影院電影售票系統?1.0\ByMovieDemo\Cinema.cs
............此處省略57個文件信息
- 上一篇:配置文件內容加密工具源碼(基于ba
se64) - 下一篇:鐵路站場簡圖繪制軟件源碼
評論
共有 條評論