用数据库设计影院售票管理系统
一.系统概述; 1.设计需求;
现在中国大部分的家庭都喜欢在家里置办属于自己风格的家庭影院。但是,仍然有
很多人喜欢到电影院去看电影。因为家里的气氛毕竟不如影院好。所以,现代家庭影院的出现并不会让电影院没有生路。
每个社会服务系统都有自己的一套管理机制。当然,电影院也不除外。其实电影院的管理系统应该来说比其他的社会服务系统的管理要简单一点。电影院不外乎是引进电影,制定播放影片的时间表,买票,检票进场观看,还有就是一些数据管理方面的事。如工作人员管理,票务管理等等。为了工作机制简单有序,必然要引进一套管理系统。
2.需求分析;
具体而言,影院售票系统需要实现以下的需求:
(1) 能够对播放电影,工作人员,售票事宜,检票事宜,无用数据进行处理。 (2) 售票管理自然有专人负责,要处理各电影的电影票销售问题。当然包括退票问题,还有就是预订电影票其实也就相当于买票。两者可以当一回事处理。
(3) 检票管理事宜要完成观众进场时检票的事宜。其中包括了电影票的真假检测问题。 (4) 数据管理要处理电影的播放的次序,工作人员的管理,以及过期电影票的处理问题。
二.结构设计
验证码 价格 电影号 电影名 电影票号 -可编辑修改- 电影 电影号 上映时间 座位 电影名称 导演 座位编号 是否售出 主演 生产地 电影票 座位票价 座位号 上映时间 。
三.设计说明
1.分析与创建数据库;
根据系统的功能分析结果,影院售票管理系统将会使用Microsoft SQL Sever 2000 作为后台的数据库管理系统。本管理系统是应用于电影院中,而且需要和数据库之间进行频繁数据交换,所以采用Microsoft SQL Sever 2000 作为后台的数据库管理系统。
在本管理系统中,需要掌握影库充实信息,职工管理信息,票务管理信息,此外,由于要进行职工管理,还需要掌握使用本系统的职工。表1存储硬库信息列表,表2存储了电影院座位的相关数据连接关系,表3存储了电影票销售情况管理,表4存储了系统使用者职工的相关情况的管理列表。
表1 影库管理表---MOVIES
字段名称 数据类型 字段大小 作用 字段属性 必填字段 Movie_id Movie_name actor actress producer palydate smallint Nvarchar Nvarchar Nvarchar Nvarchar datetime 2 50 50 50 25 8 电影号 电影名称 导演 主演 制片厂 上映时间 是 是 否 否 否 是 有(无重复) 无 无 无 无 无 索引 是否主键 是 职工号 职工密码 职工信息 职工类型 表2 电影院座位管理表---SEATS
字段名称 数据类型 字段大小 作用 字段属性 必填字段 -可编辑修改-
索引 是否主键 。
seatid price soldornot smallint float smallint 2 8 2 座位号 票价 是否售出 是 是 是 有(无重复) 无 无 是 表3 电影票信息表---TICKETS
字段名称 数据类型 字段大小 作用 字段属性 必填字段 ticketsid seatid Movie_id Movie_name palydate price yanzhengma smallint smallint smallint Nvarchar datetime float smallint 2 2 2 50 8 8 2 电影票号 座位号 电影号 电影名 上映时间 价格 验证码 是 是 是 否 是 是 是 有(无重复) 有 有 无 无 无 无 是 是 索引 是否主键 表4 职工信息表---WORKERS
字段名称 workerid password leibie
根据规范化的设计理念,本管理系统的数据分成上面4个表,减少了数据的冗余,同时在这些表之间又存在着一些关联关系。这四个表之间的这两种关系表现在下图所示的关系:
数据类型 smallint smallint smallint 字段大小 2 2 2 作用 职工号 职工密码 职工类型 字段属性 必填字段 是 是 是 索引 无 无 无 是否主键 是
-可编辑修改-
。
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(\"您的工号或者密码错误\错误提示\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(\"您超出职责范围 或未选择服务系统,请重新输入!\错误提示\ 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 + \TextBox5.Text + \ Dim sql As String sql = \"insert into tickets
(ticketsid,seatid,movie_id,movie_name,palydate,price,yanzhengma) values (\" + CStr(tickethao) + \TextBox4.Text + \TextBox5.Text + \
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 '通过 MYCON 连接对象操作数据库 mycom4.CommandType = CommandType.Text '设置命令类型 tickethao = tuipiao() Catch ex As Exception
-可编辑修改-
。
MessageBox.Show(ex.ToString) End Try
If tickethao = 0 Then
MessageBox.Show(\"座位号输入错误,请重新输入!\错误\") Else Try
mycon4.Open()
mycom4.CommandText = \"delete from tickets where ticketsid=\" + CStr(tickethao) + \"\" Try
mycom4.ExecuteNonQuery()
MessageBox.Show(\"退票成功!\谢谢观看\") Catch ex As Exception MsgBox(ex.ToString) End Try
Catch ex As Exception MsgBox(ex.ToString) End Try End If
mycon4.Close() TextBox1.Text = \"\" TextBox2.Text = \"\" TextBox3.Text = \"\"
-可编辑修改-
。
TextBox4.Text = \"\" TextBox5.Text = \"\" ComboBox1.Text = \"\" revoke_seat() End Sub
Private Sub Button3_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
TextBox2.Text = ComboBox1.Text TextBox3.Text = TextBox1.Text If TextBox4.Text = \"\" Then
MessageBox.Show(\"请输入座位号!\提示\") End I
Dim mydataadapter2 As New SqlDataAdapter Dim myds2 As New DataSet Dim dt2 As New DataTable Dim mycom2 As New SqlCommand
mycon.ConnectionString = \"initial catalog=ticketbooking;user id=sa;password=;\" mycom2.Connection = mycon '通过 MYCON 连接对象操作数据库 mycom2.CommandType = CommandType.Text '设置命令类型 Try
mycon.Open()
mycom2.CommandText = \"select * from seats where seatid=\" + TextBox4.Text + \"\"
-可编辑修改-
。
mydataadapter2.SelectCommand = mycom2 mydataadapter2.Fill(myds2, \"seats\") dt2 = myds2.Tables(\"seats\") Catch ex As Exception
MessageBox.Show(ex.ToString) End Try
TextBox5.Text = dt2.Rows(0)(\"price\") mycon.Close() End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim exitform As New Form7
If exitform.ShowDialog = DialogResult.OK Then exitform.Close() Me.Close() Application.Exit() End If End Sub End Class
4. 创建检票界面
(1)创建模块的功能
对进场观众检票,如果发现有假票或无票观众不允许入内。 (2)创建模块的窗体
-可编辑修改-
。
在工程中添加一个窗体,命名为“检票系统”,用来作为检票系统窗体。界面 的设计如下图所示。 (3)代码编写
Imports System.Data.SqlClient
Public Class Form3
Inherits System.Windows.Forms.Form Dim ds1 As New DataSet
Dim sqlda1 As New SqlDataAdapter
Dim RecordCount As Integer
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
AxShockwaveFlash1.Movie = \"E:\\实验运行场\\VB.NET程序设计\\电影院票务系统\\image\\检票界面.swf\"
AxShockwaveFlash1.Play()
AxShockwaveFlash2.Movie = \"E:\\实验运行场\\VB.NET程序设计\\电影院票务系统\\image\\检票界面下.swf\"
AxShockwaveFlash2.Play()
Dim sqlcmd1 As New SqlCommand Dim str1 As String = \"select * from tickets\" sqlcmd1.Connection = sqlcn1
-可编辑修改-
。
sqlcmd1.CommandText = str1 sqlda1.SelectCommand = sqlcmd1 Try
sqlcn1.Open()
sqlcmd1.ExecuteNonQuery() Catch ex As SqlException MsgBox(ex.Message) Finally
sqlcn1.Close() End Try Try
sqlda1.Fill(ds1) Catch ex As SqlException MsgBox(ex.Message) End Try
RecordCount = ds1.Tables(0).Rows.Count TextBox6.Text = RecordCount 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 flag As Boolean = False
-可编辑修改-
。
If TextBox1.Text = \"\" Then
TextBox7.Text = \"请认真填写票号!\" TextBox1.Focus() Exit Sub End If
If TextBox2.Text = \"\" Then
TextBox7.Text = \"请填写验证码!\" TextBox2.Focus() Exit Sub End If
For i = 0 To RecordCount - 1
If TextBox1.Text = CStr(ds1.Tables(0).Rows(i)(\"ticketsid\")) And TextBox2.Text = CStr(ds1.Tables(0).Rows(i)(\"yanzhengma\")) Then flag = True Exit For End If Next
If flag = True Then Try
TextBox3.Text = ds1.Tables(0).Rows(i)(\"seatid\") TextBox4.Text = ds1.Tables(0).Rows(i)(\"movie_name\") TextBox5.Text = ds1.Tables(0).Rows(i)(\"price\")
-可编辑修改-
。
Catch ex As Exception MsgBox(ex.Message) End Try
TextBox7.Text = \"此票为真!\" Else
TextBox7.Text = \"此票为假!\" End If
TextBox6.Text = RecordCount End Sub
Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click TextBox1.Text = \"\" TextBox2.Text = \"\" TextBox3.Text = \"\" TextBox4.Text = \"\" TextBox5.Text = \"\" TextBox6.Text = \"\" TextBox7.Text = \"\" TextBox1.Focus() End Sub
Private Sub Button3_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
-可编辑修改-
。
Dim exitform As New Form7
If exitform.ShowDialog = DialogResult.OK Then exitform.Close() Me.Close() Application.Exit() End If End Sub End Class
5. 创建维护界面
(1)创建模块的功能
给数据库维护工作人员选择维护的系统数据库 (2)创建模块的设计
在工程中添加一个窗体,命名为“维护系统”,用来作为维护系统窗体。界面 的设计如下图所示。
(3)代码编写
Public Class Form8
Inherits System.Windows.Forms.Form
Private Sub Form8_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
AxShockwaveFlash1.Movie = \"E:\\实验运行场\\VB.NET程序设计\\电影院票务系统\\image\\登陆界面.swf\"
-可编辑修改-
。
AxShockwaveFlash1.Play() End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim frm4 As New Form4 frm4.Show() Me.Hide() End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim frm6 As New Form6 frm6.Show() Me.Hide() End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim frm9 As New Form9 frm9.Show() Me.Hide() End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
-可编辑修改-
。
Dim exitform As New Form7
If exitform.ShowDialog = DialogResult.OK Then exitform.Close() Me.Close() Application.Exit() End If End Sub
End Class
1.创建影库界面
(1)创建模块的功能 对电影库播放列表的管理 (2)创建模块的设计
在工程中添加一个窗体,命名为“影库系统”,用来作为影库系统窗体。界面 的设计如下图所示。
(3)代码编写
Dim sqlAdapter As New SqlDataAdapter
Dim movieRow As DataRow Dim RecordCount As Integer Dim i As Integer = 0 Dim idnum(2000) As Integer Dim CurrentPosition As Integer
-可编辑修改-
。
Sub ShowPosition()
RecordCount = DataSet11.Movies.Rows.Count If RecordCount = 0 Then TextBox1.Text = \"无记录\" Else
CurrentPosition = Me.BindingContext(DataSet11, \"Movies\").Position movieRow = DataSet11.Movies.Rows(CurrentPosition) TextBox1.Text = movieRow.Item(\"movie_id\") idnum(i) = TextBox1.Text i += 1
TextBox2.Text = movieRow.Item(\"movie_name\") TextBox3.Text = movieRow.Item(\"actor\") TextBox4.Text = movieRow.Item(\"actress\") TextBox5.Text = movieRow.Item(\"producer\") TextBox6.Text = movieRow.Item(\"palydate\")
TextBox7.Text = CurrentPosition + 1 & \"/\" & RecordCount End If End Sub
Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
DataSet11.Clear()
Me.SqlDataAdapter1.Fill(DataSet11)
-可编辑修改-
。
ShowPosition() End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Me.BindingContext(DataSet11, \"Movies\").Position > 0 Then Me.BindingContext(DataSet11, \"Movies\").Position -= 1 ShowPosition() Else
MessageBox.Show(\"已到达首记录!\提示信息\") End If End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If Me.BindingContext(DataSet11, \"Movies\").Position < RecordCount - 1 Then Me.BindingContext(DataSet11, \"Movies\").Position += 1 ShowPosition() Else
MessageBox.Show(\"已到达尾记录!\提示信息\") End If End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
-可编辑修改-
。
Me.BindingContext(DataSet11, \"Movies\").Position = RecordCount - 1 ShowPosition() End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click '添加数据 Dim j As Integer
Dim flag As Boolean = True For j = 0 To i
If TextBox1.Text = CStr(idnum(j)) Then flag = False
MessageBox.Show(\"ID地址有冲突!\提示\") End If Next
If flag = True Then
Dim MyNewData As DataRow
MyNewData = DataSet11.Movies.NewRow Try
With MyNewData .BeginEdit()
If TextBox1.Text <> \"\" Then
.Item(\"movie_id\") = TextBox1.Text Else
-可编辑修改-
。
MessageBox.Show(\"编号不能为空\") Return End If
.Item(\"movie_name\") = TextBox2.Text .Item(\"actor\") = TextBox3.Text .Item(\"actress\") = TextBox4.Text .Item(\"producer\") = TextBox5.Text .Item(\"palydate\") = TextBox6.Text .EndEdit() End With Catch ex As Exception
MessageBox.Show(ex.Message) Return End Try
DataSet11.Movies.Rows.Add(MyNewData) Try
Dim i As Integer = SqlDataAdapter1.Update(DataSet11, \"Movies\") DataSet11.AcceptChanges()
MessageBox.Show(i & \"条记录添加成功!\") Catch ex As Exception
MessageBox.Show(ex.Message) End Try
-可编辑修改-
。
idnum(i) = TextBox1.Text i = i + 1 End If End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click '修改数据 Dim j As Integer For j = 0 To i
If TextBox1.Text = CStr(idnum(j)) Then
MessageBox.Show(\"ID地址有冲突!\提示\") End If Next
CurrentPosition = Me.BindingContext(DataSet11, \"Movies\").Position movieRow = DataSet11.Movies.Rows(CurrentPosition) Try
With movieRow .BeginEdit()
.Item(\"movie_id\") = TextBox1.Text .Item(\"movie_name\") = TextBox2.Text .Item(\"actor\") = TextBox3.Text .Item(\"actress\") = TextBox4.Text .Item(\"producer\") = TextBox5.Text
-可编辑修改-
。
.Item(\"palydate\") = TextBox6.Text .EndEdit() End With
Catch ex As Exception
MessageBox.Show(ex.Message) Return End Try Try
Dim i As Integer = SqlDataAdapter1.Update(DataSet11, \"Movies\") DataSet11.AcceptChanges()
MessageBox.Show(i & \"条记录修改成功!\") Catch ex As Exception
MessageBox.Show(ex.Message) End Try End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Me.BindingContext(DataSet11, \"Movies\").Position = 0 ShowPosition() End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click '删除数据
-可编辑修改-
。
CurrentPosition = Me.BindingContext(DataSet11, \"Movies\").Position movieRow = DataSet11.Movies.Rows(CurrentPosition) Dim n As Integer = movieRow.Item(\"movie_id\") Dim j As Integer = 0 For j = 0 To i
If n = idnum(j) Then idnum(j) = -1 End If Next
movieRow.Delete() Try
Dim i As Integer = SqlDataAdapter1.Update(DataSet11, \"Movies\") DataSet11.AcceptChanges()
MessageBox.Show(i & \"条记录删除成功!\") Catch ex As Exception
MessageBox.Show(ex.Message) End Try End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
Dim exitform As New Form7
If exitform.ShowDialog = DialogResult.OK Then
-可编辑修改-
。
exitform.Close() Me.Close() Application.Exit() End If End Sub
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
Dim frm8 As New Form8 frm8.Show() Me.Close() End Sub End Class
2.创建职工界面
(1)创建模块的功能
对职工数据的处理。如增加、删除和更改 (2)创建模块的设计
在工程中添加一个窗体,命名为“影库系统”,用来作为影库系统窗体。界面 的设计如下图所示。
(3)代码编写
Inherits System.Windows.Forms.Form
-可编辑修改-
。
Dim frm8 As New Form8
Dim sqlAdapter As New SqlDataAdapter Dim movieRow As DataRow Dim RecordCount As Integer Dim i As Integer = 0 Dim idnum(2000) As Integer Dim CurrentPosition As Integer Sub ShowPosition()
RecordCount = DataSet11.Workers.Rows.Count If RecordCount = 0 Then TextBox1.Text = \"无记录\" Else
CurrentPosition = Me.BindingContext(DataSet11, \"Workers\").Position movieRow = DataSet11.Workers.Rows(CurrentPosition) TextBox1.Text = movieRow.Item(\"workerid\") idnum(i) = TextBox1.Text i += 1
TextBox2.Text = movieRow.Item(\"password\") TextBox3.Text = movieRow.Item(\"leibie\")
TextBox4.Text = CurrentPosition + 1 & \"/\" & RecordCount End If End Sub
-可编辑修改-
。
Private Sub Form6_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
DataSet11.Clear()
Me.SqlDataAdapter1.Fill(DataSet11) ShowPosition() End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Me.BindingContext(DataSet11, \"Workers\").Position > 0 Then Me.BindingContext(DataSet11, \"Workers\").Position -= 1 ShowPosition() Else
MessageBox.Show(\"已到达首记录!\提示信息\") End If End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If Me.BindingContext(DataSet11, \"Workers\").Position < RecordCount - 1 Then Me.BindingContext(DataSet11, \"Workers\").Position += 1 ShowPosition() Else
MessageBox.Show(\"已到达尾记录!\提示信息\")
-可编辑修改-
。
End If End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Me.BindingContext(DataSet11, \"Workers\").Position = 0 ShowPosition() End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Me.BindingContext(DataSet11, \"Workers\").Position = RecordCount - 1 ShowPosition() End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim j As Integer
Dim flag As Boolean = True For j = 0 To i
If TextBox1.Text = CStr(idnum(j)) Then flag = False
MessageBox.Show(\"ID地址有冲突!\提示\") End If Next
-可编辑修改-
。
If TextBox3.Text <> 1 And TextBox3.Text <> 2 And TextBox3.Text <> 3 Then flag = False
MessageBox.Show(\"服务系统号只能为1,2,3!\提示\") End If
If flag = True Then
Dim MyNewData As DataRow
MyNewData = DataSet11.Workers.NewRow Try
With MyNewData .BeginEdit()
If TextBox1.Text <> \"\" Then
.Item(\"workerid\") = TextBox1.Text Else
MessageBox.Show(\"编号不能为空\") Return End If
.Item(\"password\") = TextBox2.Text .Item(\"leibie\") = TextBox3.Text .EndEdit() End With Catch ex As Exception
MessageBox.Show(ex.Message)
-可编辑修改-
。
Return End Try
DataSet11.Workers.Rows.Add(MyNewData) Try
Dim k As Integer = SqlDataAdapter1.Update(DataSet11, \"Workers\") DataSet11.AcceptChanges()
MessageBox.Show(k & \"条记录添加成功!\") Catch ex As Exception
MessageBox.Show(ex.Message) End Try
idnum(i) = TextBox1.Text i = i + 1 End If End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Dim j As Integer For j = 0 To i
If TextBox1.Text = CStr(idnum(j)) Then
MessageBox.Show(\"ID地址有冲突!\提示\") End If Next
-可编辑修改-
。
If TextBox3.Text <> 1 And TextBox3.Text <> 2 And TextBox3.Text <> 3 Then MessageBox.Show(\"服务系统号只能为1,2,3!\提示\") End If
CurrentPosition = Me.BindingContext(DataSet11, \"Workers\").Position movieRow = DataSet11.Workers.Rows(CurrentPosition) Try
With movieRow .BeginEdit()
.Item(\"workerid\") = TextBox1.Text .Item(\"password\") = TextBox2.Text .Item(\"leibie\") = TextBox3.Text .EndEdit() End With
Catch ex As Exception
MessageBox.Show(ex.Message) Return End Try Try
Dim k As Integer = SqlDataAdapter1.Update(DataSet11, \"Workers\") DataSet11.AcceptChanges()
MessageBox.Show(k & \"条记录修改成功!\") Catch ex As Exception
-可编辑修改-
。
MessageBox.Show(ex.Message) End Try End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
CurrentPosition = Me.BindingContext(DataSet11, \"Workers\").Position movieRow = DataSet11.Workers.Rows(CurrentPosition) Dim n As Integer = movieRow.Item(\"workerid\") Dim j As Integer = 0 For j = 0 To i
If n = idnum(j) Then idnum(j) = -1 End If Next
movieRow.Delete() Try
Dim k As Integer = SqlDataAdapter1.Update(DataSet11, \"Workers\") DataSet11.AcceptChanges()
MessageBox.Show(k & \"条记录删除成功!\") Catch ex As Exception
MessageBox.Show(ex.Message) End Try
-可编辑修改-
。
End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
Dim exitform As New Form7
If exitform.ShowDialog = DialogResult.OK Then exitform.Close() Me.Close() Application.Exit() End If frm8.Close() End Sub
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click Me.Close() frm8.Show() End Sub End Class
3.创建票务界面
(1)创建模块的功能
对所售出的电影票进行管理,把没用的数据进行清除 (2)创建模块的设计
在工程中添加一个窗体,命名为“影库系统”,用来作为影库系统窗体。界面 的设计如下图所示。
-可编辑修改-
。
(3)代码编写
Imports System.Data.SqlClient
Public Class Form9
Inherits System.Windows.Forms.Form Dim ds1 As New DataSet
Dim sqlda1 As New SqlDataAdapter Dim RecordCount As Integer
Private Sub Form9_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim sqlcmd1 As New SqlCommand
Dim str1 As String = \"SELECT Movies.movie_id, Movies.movie_name, Movies.actor, Movies.actress, Movies.producer, Movies.palydate FROM Movies INNER JOIN Tickets ON Movies.movie_name = Tickets.movie_name\" sqlcmd1.Connection = sqlcn1 sqlcmd1.CommandText = str1 sqlda1.SelectCommand = sqlcmd1 Try
sqlcn1.Open()
sqlcmd1.ExecuteNonQuery()
-可编辑修改-
。
Catch ex As SqlException MsgBox(ex.Message) Finally
sqlcn1.Close() End Try Try
sqlda1.Fill(ds1) Catch ex As SqlException MsgBox(ex.Message) End Try
RecordCount = ds1.Tables(0).Rows.Count End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Integer
Dim flag As Boolean = False If TextBox1.Text = \"\" Then
MessageBox.Show(\"请认真填写电影名!\提示信息\") TextBox1.Focus() Else
For i = 0 To RecordCount - 1
If CStr(ds1.Tables(0).Rows(i).Item(\"movie_name\")).Trim = CStr(TextBox1.Text) Then
-可编辑修改-
。
Try
TextBox2.Text = CStr(ds1.Tables(0).Rows(i).Item(\"movie_id\")) TextBox3.Text = CStr(ds1.Tables(0).Rows(i).Item(\"movie_name\")) TextBox4.Text = CStr(ds1.Tables(0).Rows(i).Item(\"actor\")) TextBox5.Text = CStr(ds1.Tables(0).Rows(i).Item(\"actress\")) TextBox6.Text = CStr(ds1.Tables(0).Rows(i).Item(\"producer\")) TextBox7.Text = CStr(ds1.Tables(0).Rows(i).Item(\"palydate\")) Catch ex As Exception MsgBox(ex.Message) End Try flag = True Exit Sub End If Next End If
If flag = False Then
MessageBox.Show(\"输入电影名有误!\提示\") End If End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
DataSet11.Clear()
-可编辑修改-
。
Me.SqlDataAdapter1.Fill(DataSet11) Dim i As Integer Dim k As Integer
k = DataSet11.Tickets.Rows.Count Dim flag As Boolean = False If TextBox1.Text = \"\" Then
MessageBox.Show(\"请认真填写电影名!\提示信息\") TextBox1.Focus() Exit Sub Else
For i = 0 To k - 1
If CStr(DataSet11.Tickets.Rows(i).Item(\"movie_name\")).Trim = CStr(TextBox1.Text) Then
DataSet11.Tickets.Rows(i).Delete() flag = True End If Next Try
Dim j As Integer = SqlDataAdapter1.Update(DataSet11, \"Tickets\") DataSet11.AcceptChanges()
MessageBox.Show(j & \"条记录删除成功!\") Catch ex As Exception
-可编辑修改-
。
MessageBox.Show(ex.Message) End Try End If
If flag = False Then
MessageBox.Show(\"输入电影名有误!\提示\") End If End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim frm8 As New Form8 frm8.Show() Me.Close() End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim exitform As New Form7
If exitform.ShowDialog = DialogResult.OK Then exitform.Close() Me.Close() Application.Exit() End If End Sub
-可编辑修改-
。
End Cla
-可编辑修改-
。
THANKS !!!
致力为企业和个人提供合同协议,策划案计划书,学习课件等等
打造全网一站式需求
欢迎您的下载,资料仅供参考
-可编辑修改-
因篇幅问题不能全部显示,请点此查看更多更全内容