资源描述
一.系统概述;
1.设计需求;
现在中国大部分的家庭都喜欢在家里置办属于自己风格的家庭影院。但是,仍然有很多人喜欢到电影院去看电影.因为家里的气氛毕竟不如影院好。所以,现代家庭影院的出现并不会让电影院没有生路。
每个社会服务系统都有自己的一套管理机制.当然,电影院也不除外.其实电影院的管理系统应该来说比其他的社会服务系统的管理要简单一点。电影院不外乎是引进电影,制定播放影片的时间表,买票,检票进场观看,还有就是一些数据管理方面的事。如工作人员管理,票务管理等等.为了工作机制简单有序,必然要引进一套管理系统。
2.需求分析;
具体而言,影院售票系统需要实现以下的需求:
(1) 能够对播放电影,工作人员,售票事宜,检票事宜,无用数据进行处理。
(2) 售票管理自然有专人负责,要处理各电影的电影票销售问题。当然包括退票问题,还有就是预订电影票其实也就相当于买票。两者可以当一回事处理。
(3) 检票管理事宜要完成观众进场时检票的事宜。其中包括了电影票的真假检测问题.
(4) 数据管理要处理电影的播放的次序,工作人员的管理,以及过期电影票的处理问题。
电影
电影号
电影名称
主演
导演
生产地
上映时间
二.结构设计座位
座位编号
座位票价
是否售出
电影票
电影号
电影名
座位号
价格
电影票号
上映时间 映时间
验证码
职工信息
职工号
职工类型
职工密码
三.设计说明
1.分析与创建数据库;
根据系统的功能分析结果,影院售票管理系统将会使用Microsoft SQL Sever 2000 作为后台的数据库管理系统。本管理系统是应用于电影院中,而且需要和数据库之间进行频繁数据交换,所以采用Microsoft SQL Sever 2000 作为后台的数据库管理系统。
在本管理系统中,需要掌握影库充实信息,职工管理信息,票务管理信息,此外,由于要进行职工管理,还需要掌握使用本系统的职工.表1存储硬库信息列表,表2存储了电影院座位的相关数据连接关系,表3存储了电影票销售情况管理,表4存储了系统使用者职工的相关情况的管理列表.
表1 影库管理表-——MOVIES
字段名称
数据类型
字段属性
字段大小
作用
必填字段
索引
是否主键
Movie_id
smallint
2
电影号
是
有(无重复)
是
Movie_name
Nvarchar
50
电影名称
是
无
actor
Nvarchar
50
导演
否
无
actress
Nvarchar
50
主演
否
无
producer
Nvarchar
25
制片厂
否
无
palydate
datetime
8
上映时间
是
无
表2 电影院座位管理表-—-SEATS
字段名称
数据类型
字段属性
字段大小
作用
必填字段
索引
是否主键
seatid
smallint
2
座位号
是
有(无重复)
是
price
float
8
票价
是
无
soldornot
smallint
2
是否售出
是
无
表3 电影票信息表—-—TICKETS
字段名称
数据类型
字段属性
字段大小
作用
必填字段
索引
是否主键
ticketsid
smallint
2
电影票号
是
有(无重复)
是
seatid
smallint
2
座位号
是
有
Movie_id
smallint
2
电影号
是
有
Movie_name
Nvarchar
50
电影名
否
无
palydate
datetime
8
上映时间
是
无
price
float
8
价格
是
无
yanzhengma
smallint
2
验证码
是
无
是
表4 职工信息表—--WORKERS
字段名称
数据类型
字段属性
字段大小
作用
必填字段
索引
是否主键
workerid
smallint
2
职工号
是
无
是
password
smallint
2
职工密码
是
无
leibie
smallint
2
职工类型
是
无
根据规范化的设计理念,本管理系统的数据分成上面4个表,减少了数据的冗余,同时在这些表之间又存在着一些关联关系。这四个表之间的这两种关系表现在下图所示的关系:
2.创建登陆窗体模块;
(1)窗体模块的功能
登陆窗体
(2)窗体界面的设计
在工程中添加一个窗体,命名为“登陆系统”,用来作为系统登陆窗体。界面
的设计如图3所示。
(3)窗体代码
Imports System。Data。SqlClient
Public Class Form1
Inherits System.Windows.Forms.Form
Dim navigator As BindingManagerBase '用来对记录导航
Dim mycon As New SqlConnection '连接对象
Dim mycom As New SqlCommand '命令对象
Dim mycom1 As New SqlCommand
Dim frm2 As New Form2
Dim frm3 As New Form3
Dim frm8 As New Form8
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1。Tick
StatusBar1.Panels(0).Text = DateTime。Today
StatusBar1。Panels(1).Text = DateTime。Now.ToString(”T”)
End Sub
Private Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox1。Enter
If RadioButton1.Checked = True Then
RadioButton2。Checked = False
RadioButton3。Checked = False
ElseIf RadioButton2。Checked = True Then
RadioButton1.Checked = False
RadioButton3。Checked = False
ElseIf RadioButton3.Checked = True Then
RadioButton1。Checked = False
RadioButton2。Checked = False
End If
End Sub
Private Sub Button1_Click(ByVal sender As System。Object, ByVal e As System.EventArgs) Handles Button1。Click
AxShockwaveFlash1。Movie = "E:\实验运行场\VB。NET程序设计\电影院票务系统\image\登陆界面1。swf”
AxShockwaveFlash1.Playing = False
AxShockwaveFlash1。Stop()
Dim tox1 As Int32
Dim tox2 As Int32
Dim mydataadapter As New SqlDataAdapter
Dim myds As New DataSet
Dim i As Integer
Dim j As Integer
tox1 = Val(TextBox1。Text)
tox2 = Val(TextBox2.Text)
mycon。ConnectionString = ”initial catalog=ticketbooking;user id=sa;password=;"
mycom。Connection = mycon ’通过 MYCON 连接对象操作数据库
mycom。CommandType = CommandType。Text ’设置命令类型
mycom.CommandText = "select * from workers” '设置要执行的命令
Try
mycon。Open()
mydataadapter.SelectCommand = mycom
Catch ex As Exception
MessageBox.Show("连接失败”)
Finally
mycon。Close()
End Try
mydataadapter。Fill(myds, ”workers”)
For i = 0 To myds。Tables(”workers”)。Rows。Count — 1
If tox1 = Val(myds。Tables("workers")。Rows(i).ItemArray(0)) Then
j = 0
Exit For
Else
j = 1
End If
Next
For i = 0 To myds。Tables("workers”).Rows。Count — 1
If tox2 = Val(myds。Tables(”workers”)。Rows(i)。ItemArray(1)) Then
j = 0
Exit For
Else
j = 1
End If
Next
If j = 1 Then
MessageBox。Show(”您的工号或者密码错误", "错误提示”, MessageBoxButtons。OK, MessageBoxIcon.Warning)
Else
Try
mycom1。Connection = mycon ’通过 MYCON 连接对象操作数据库
mycom1。CommandType = CommandType.Text ’设置命令类型
mycom1。CommandText = ”select leibie from workers where workerid=” + CStr(tox1) + "and password=" + CStr(tox2) + ”" '设置要执行的命令
Dim mydataadapter1 As New SqlDataAdapter
mydataadapter1。SelectCommand = mycom1
Dim myds1 As New DataSet
mydataadapter1.Fill(myds1, ”workers”)
If RadioButton1。Checked = True And Val(myds1.Tables(”workers”)。Rows(0)("leibie”)) = 1 Then
frm2。Show()
Me。Hide()
ElseIf RadioButton2。Checked = True And Val(myds1.Tables(”workers").Rows(0)(”leibie")) = 2 Then
frm3.Show()
Me。Hide()
ElseIf RadioButton3。Checked = True And Val(myds1.Tables(”workers")。Rows(0)(”leibie”)) = 3 Then
frm8。Show()
Me。Hide()
Else
MessageBox。Show("您超出职责范围 或未选择服务系统,请重新输入!”, ”错误提示”, MessageBoxButtons。OK, MessageBoxIcon。Warning, MessageBoxDefaultButton。Button1)
End If
Catch ex As Exception
End Try
End If
End Sub
Private Sub Form1_Load(ByVal sender As System。Object, ByVal e As System。EventArgs) Handles MyBase。Load
AxShockwaveFlash1.Movie = "E:\实验运行场\VB。NET程序设计\电影院票务系统\image\登陆界面1。swf"
AxShockwaveFlash1。Play()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim exitform As New Form7
If exitform.ShowDialog = DialogResult.OK Then
exitform.Close()
Me.Close()
Application。Exit()
End If
End Sub
End Class
3. 创建售票窗体模块
(1) 窗体模块的功能
为观众提供买票服务。在界面上观众可以看见座位的情况,根据此来选择自己喜欢的座位.不同的座位有不同的价格。此窗体还有退票功能。
(2) 窗体界面的设计
在工程中添加一个窗体,命名为“售票系统”,用来作为仓管人员窗体.界面
的设计如下图所示。
(3) 代码编写
Imports System。Data。SqlClient
Public Class Form2
Inherits System.Windows.Forms.Form
Dim navigator As BindingManagerBase ’用来对记录导航
Dim mycon As New SqlConnection '连接对象
Dim mycom As New SqlCommand ’命令对象
Private Sub Form2_Load(ByVal sender As System。Object, ByVal e As System。EventArgs) Handles MyBase.Load
’Me.Show()
AxShockwaveFlash1。Movie = ”E:\实验运行场\VB。NET程序设计\电影院票务系统\image\销售界面.swf"
AxShockwaveFlash1.Play()
AxShockwaveFlash2。Movie = ”E:\实验运行场\VB。NET程序设计\电影院票务系统\image\检票界面下.swf”
AxShockwaveFlash2。Play()
Dim mydataadapter As New SqlDataAdapter
Dim myds As New DataSet
Dim i As Integer
Dim j As Integer
Dim strrow As String
Dim dt As New DataTable
mycon。ConnectionString = "initial catalog=ticketbooking;user id=sa;password=;”
mycom。Connection = mycon ’通过 MYCON 连接对象操作数据库
mycom。CommandType = CommandType.Text '设置命令类型
mycom.CommandText = "select * from Movies” '设置要执行的命令”
Try
mycon.Open()
mydataadapter.SelectCommand = mycom
mydataadapter.Fill(myds, ”Movies”)
Catch ex As Exception
MessageBox。Show(”连接失败”)
Finally
mycon。Close()
End Try
Try
For i = 0 To myds.Tables(”Movies”).Rows。Count - 1
strrow = myds。Tables(”Movies”)。Rows(i)("movie_name”)
ComboBox1.Items。Add(strrow)
Next
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Sub
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System。EventArgs) Handles Button1。Click
Dim i As Integer
Dim tickethao As Integer
Dim moviehao As Integer
Dim suiji As Integer
Dim mydataadapter3 As New SqlDataAdapter
Dim myds3 As New DataSet
Dim dt3 As New DataTable
Dim mycom3 As New SqlCommand
Dim mycon3 As New SqlConnection
Randomize()
suiji = Int(9000 * Rnd() + 1000)
Try
tickethao = tickets_id()
moviehao = movieid()
mycon3.ConnectionString = ”initial catalog=ticketbooking;user id=sa;password=;"
mycom3.Connection = mycon3 ’通过 MYCON 连接对象操作数据库
mycom3.CommandType = CommandType。Text ’设置命令类型
Catch ex As Exception
MessageBox。Show(ex。ToString)
End Try
If tickethao = 0 Then
Try
MessageBox.Show("此座位已售出,请重新选择!", "错误")
ComboBox1.Text = "”
TextBox1。Text = ”"
TextBox2。Text = ""
TextBox3。Text = ""
TextBox4.Text = "”
TextBox5.Text = "”
Catch ex As Exception
MessageBox。Show(ex.ToString)
End Try
Else
Try
mycon3.Open()
mycom3。CommandText = "insert into tickets (ticketsid,seatid,movie_id,movie_name,palydate,price,yanzhengma) values (” + CStr(tickethao) + "," + TextBox4。Text + ”," + CStr(moviehao) + ",’” + TextBox2。Text + "',’” + TextBox1。Text + ”',” + TextBox5.Text + "," + CStr(suiji) + ”)”
Dim sql As String
sql = "insert into tickets (ticketsid,seatid,movie_id,movie_name,palydate,price,yanzhengma) values (” + CStr(tickethao) + ",” + TextBox4.Text + ”," + CStr(moviehao) + ",'” + TextBox2.Text + ”’,’" + TextBox3.Text + ”’," + TextBox5.Text + ",” + CStr(suiji) + ”)”
mydataadapter3.InsertCommand = mycom3
Try
mycom3。ExecuteNonQuery()
MessageBox.Show(”售票成功!", "谢谢观看")
Catch ex As Exception
MsgBox(ex。ToString)
End Try
Catch ex As Exception
MessageBox。Show(ex.ToString)
End Try
mycon3.Close()
ComboBox1.Text = ”"
TextBox1。Text = "”
TextBox2。Text = ""
TextBox3。Text = ””
TextBox4.Text = "”
TextBox5。Text = ”"
End If
revoke_seat()
End Sub
Private Sub ComboBox1_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal e As System。EventArgs) Handles ComboBox1。SelectedIndexChanged
revoke_seat()
Dim mydataadapter1 As New SqlDataAdapter
Dim mydataadapter11 As New SqlDataAdapter
Dim myds1 As New DataSet
Dim myds11 As New DataSet
Dim dt1 As New DataTable
Dim dt11 As New DataTable
Dim mycom1 As New SqlCommand
Dim mycom11 As New SqlCommand
mycon。ConnectionString = "initial catalog=ticketbooking;user id=sa;password=;"
mycom1。Connection = mycon '通过 MYCON 连接对象操作数据库
mycom1.CommandType = CommandType。Text '设置命令类型
mycom11。Connection = mycon
mycom11.CommandType = CommandType.Text
Try
mycon.Open()
mycom11.CommandText = ”select palydate from Movies where movie_name= '” + ComboBox1。Text + "'”
mycom1.CommandText = "select * from tickets where movie_name= ’" + ComboBox1.Text + "'"
mydataadapter1。SelectCommand = mycom1
mydataadapter11。SelectCommand = mycom11
mydataadapter1.Fill(myds1, "tickets")
mydataadapter11。Fill(myds11, "Movies”)
dt1 = myds1.Tables("tickets")
dt11 = myds11.Tables("Movies")
Catch ex As Exception
MessageBox.Show(ex。ToString)
End Try
Try
If dt1。Rows.Count = 0 Then
MessageBox。Show("还未出售!”)
TextBox1.Text = dt11.Rows(0)("palydate")
revoke_seat()
Else
ShowSellInfo(dt1)
TextBox1.Text = dt11.Rows(0)("palydate”)
End If
Catch ex As Exception
End Try
mycon。Close()
End Sub
Private Sub Button2_Click_1(ByVal sender As System。Object, ByVal e As System。EventArgs) Handles Button2.Click
Dim tickethao As Integer
Dim mydataadapter4 As New SqlDataAdapter
Dim myds4 As New DataSet
Dim dt4 As New DataTable
Dim mycom4 As New SqlCommand
Dim mycon4 As New SqlConnection
Try
mycon4。ConnectionString = "initial catalog=ticketbooking;user id=sa;password=;”
mycom4。Connection = mycon4
展开阅读全文