100分请教如何实现电影院里选座位功能?C# winform窗体程序

netboygg 2012-05-08 03:44:56
我想实现一个类似于我们去电影院买票选座位的程序,不知道有人会么?谢谢!
...全文
6102 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
boyqing 2012-05-08
  • 打赏
  • 举报
回复
/// <summary>
/// 初始化座位
/// </summary>
/// <param name="seatRow">行数</param>
/// <param name="seatLine">列数</param>
/// <param name="tb"></param>
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.AutoSize = false;
label.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,((byte)(134)));
label.Location = new System.Drawing.Point(59, 60);
label.Name = "lbl" + (j + 1).ToString() + "_" + (i + 1).ToString();
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);
}
}
}

/// <summary>
/// 点击一个座位
/// 买票事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void lblSeat_Click(object sender, EventArgs e)
{
if (String.IsNullOrEmpty(this.lblMovieName.Text))
{
MessageBox.Show("您还没选择电影");
return;
}
ticket++;
try
{
string seatNum = ((Label)sender).Text.ToString();
string customerName = this.txtCustomer.Text.ToString();
int discount = 0;
string type = "";
if (this.rdoStudent.Checked)
{
type = "student";
if (this.cmbDisCount.Text == null)
{
MessageBox.Show("请输入折扣数");
return;
}
else
{
discount = int.Parse(this.cmbDisCount.Text);
}
}
else if (this.rdoFree.Checked)
{
if (String.IsNullOrEmpty(this.txtCustomer.Text))
{
MessageBox.Show("请输入赠票者姓名");
return;
}
else
{
type = "free";
}
}


//调用工厂创建票
Ticket newTicket = TicketFactory.CreateTicket(cinema.Schedule.Items[key], cinema.Seats[seatNum],
discount, customerName, type);
if (cinema.Seats[seatNum].Color == Color.Yellow)
{
//打印
DialogResult result;
result = MessageBox.Show("是否购买?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
if (result == DialogResult.Yes)
{
cinema.Seats[seatNum].Color = Color.Red;
UpdateSeat();
cinema.SoldTickets.Add(newTicket);
newTicket.CalcPrice();
lblCalcPrice.Text = newTicket.Price.ToString();
newTicket.Print();
}
else if (result == DialogResult.No)
{
return;
}
}
else
{
MessageBox.Show("已售出.");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}

如果还看不明白,留Email发给你
jacie0617 2012-05-08
  • 打赏
  • 举报
回复
这个主要是你的数据库设计的合理,实现就简单了。
wy811007 2012-05-08
  • 打赏
  • 举报
回复 1
话说你去51aspx 搜索下 我记得有影院系统滴..
jyh070207 2012-05-08
  • 打赏
  • 举报
回复
应该和火车票的系统差不多吧,座位可分为不同等级及价位,每一个不同放映时间产生一个所有座位号可售的清单,售票时标识已售的座位号,选座位只能从没有没有售出中的选,
facelessvoidhj 2012-05-08
  • 打赏
  • 举报
回复
就是上面模拟电影院的座位那样的么?点击那个座位就变成选中状态,表示票已经卖出去了。
mizuho_2006 2012-05-08
  • 打赏
  • 举报
回复
选座位的规则是什么啊?
sunylf 2012-05-08
  • 打赏
  • 举报
回复
電影院的座位有什麼好選擇的?前排,中排,后排,左邊,右邊,中間?

110,567

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧