汽车销售系统实训报告

更新时间:2024-06-19 16:34:01 阅读量: 综合文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

学生姓名: 专业: 班级: 学号:

小组成员

学号 姓名 600942003 张娇(组长) 600942028 劳明英 600942012 钱国兵 600942016 何苗 各成员任务:钱国兵完成U/C矩阵的规划和汽车ppt的展示;劳明英和张娇完成干特图的绘制和工程制作;何苗 完成汽车销售的主要业务过程;张娇完成汽车销售系统实训报告的编制。

一、 汽车销售管理系统规划方法的选择:

企业系统规划法BSP法

企业系统规划法(Business System Planning, 简称BSP法)是一种能根据企业目标制定出MIS战略规划的结构化方法.

作用 1. 确定未来信息系统的总体结构,明确系统的子系统组成和开发子系统的先后顺序;

2. 对数据进行统一规划,管理和控制,明确各子系统之间的数据交换关系,保证信息的一致性. BSP法的优点

能保证信息系统独立于企业的组织机构,即使将来企业的组织机构或管理体制发生变化,信息系统的结构体系不会受到太大的冲击.

二、 规划步骤:

汽车销售管理系统是典型的信息管理系统(MIS),其开发主要包括后台数据库的建立和维护,以及前台应用程序的开发两个方面。对于前者,要求建立起数据一致和完整性强、数据安全性好的库。而对于后者,则要求应用程序具有功能完备、易使用等特点。

随着科学技术的不断提高,计算机科学日趋成熟,其强大的功能已被人们深刻认识到。它已进入人类社会的各个领域并发挥着越来越重要的作用。作为计算机应用的一部分,使用计算机对汽车销售信息进行管理,具有手工管理所无法比拟的优点。例如,迅速检索、查找方便、可靠性高、存储量大、保密性好、寿命长、成本低等。这些优点能够极大地提高汽车销售管理的效率,也使得企业可以进行科学化、正规化管理,这是与世界接轨的重要条件。 需求分析

现某汽车销售公司需要管理其各种信息,实现办公的信息化,通过建立一个汽车销售管理系统来管理企业。该系统完成的功能主要如下:

(1)能够实现对入库及销售信息的各种查询,包括逐个浏览,以及对入库及销售信息的增加、删除和编辑操作。另外,可以根据输入的信息来检索某车辆的信息。 (2)根据车辆信息进行汇总。

3)另外,管理人员也可以直接增加和删除用户信息。系统还可以提供一定的附加功能来方便用户。

1、 调查某汽车公司现状

X汽车销售公司现状分析

X汽车销售公司具备熟练操作计算机的员工,可使用计算机办公应用软件如OFFICE系列进行日常的信息处理。但是缺乏汽车销售管理的专门软件对有关销售的业务进行统一管理,希望能有一个适合本公司的汽车销售管理系统以提高销售业务的效率。

汽车销售管理系统的用户需求

X汽车销售公司需要管理其各种信息,实现办公的信息化,通过建立一个汽车销售管理系统来管理企业。该系统完成的功能主要如下:

(1)能够实现对入库及销售信息的各种查询,包括逐个浏览,以及对入库及销售信息的增加、删除和编辑操作。另外,可以根据输入的信息来检索某车辆的信息。

(2)根据车辆信息进行汇总。

(3)另外,管理人员也可以直接增加和删除用户信息。系统还可以提供一定的附加功能来方便用户。

系统开发方法的选择 :委托开发

2、 定义汽车销售的主要业务过程

(1)入库管理

通过输入入库单号、车辆名称、日期、库存位号、入库数量和经手人以查询入库货品信息,了解货品的单价、数量、单位、金额和供应商名称。 (2)销售管理

通过输入提库单号、车辆名称、出库日期、提货数量、经手人和备注以查询出售的货物信息 (3)系统管理

此中包括增加用户、修改密码和退出系统。其中增加用户通过输入用户名、密码及确认密码最后选择用户权限以增加可以浏览销售管理系统的用户; 修改密码提供新密码和确认密码界面。 (4)查询管理

查询管理提供两种查询方式:按入库单号和按日期查询。 (5)车辆汇总

车辆汇总提供按日期、按供应商、按入库单和按入库单加日期五种方式汇总车辆信息

3.业务过程重组 ; 4.定义和确定数据类 ;

用户信息:包括新增用户和修改密码 库存信息:包括入库管理 销售信息:包括销售管理

库存汇总信息:包括按日期汇总库存、按入库单汇总、按入库单+日期汇总、按供应 商汇总

5.设计管理信息系统总体结构 用UC矩阵法划分子系统

U/C矩阵法

实现子系统划分的方法很多,\矩阵法\是其中较为常用和有效的方法. U/C矩阵法的六个步骤 ⑴ 填入\数据类\⑵ 填入\功能\⑶ 标以\或\

⑷ 按逻辑关系及发生的顺序,重排各功能; ⑸ 重排数据类,使所有\尽可能靠近对角线; ⑹ 分组(如下图所示)

6.确定子系统开发的先后顺序 ;

7.完成BSP研究报告,形成文档,建议书以及开发计划 8.干特图的绘制: 干特图如下:

三. 系统分析与设计

1.了解用户需求,即:清楚用户需要一个什么样的系统以及该系统所具备的功能。

X汽车销售公司需要管理其各种信息,实现办公的信息化,通过建立一个汽车销售管理

系统来管理企业。该系统完成的功能主要如下:

(1)能够实现对入库及销售信息的各种查询,包括逐个浏览,以及对入库及销售信息的增加、删除和编辑操作。另外,可以根据输入的信息来检索某车辆的信息。

(2)根据车辆信息进行汇总。

(3)另外,管理人员也可以直接增加和删除用户信息。系统还可以提供一定的附加功能来方便用户。

2.进行系统总体设计,画出系统总体结构图。 系统功能模块如图所示:

汽车销售管理系统 系统 管理 入库 管理 信息 维护 销售 管理 查询 管理 车辆 汇总 增加 新用 户 修改 密码 退出 系统 入库 信息 维护 销售 信息 维护 车辆 基本 资料 维护 入库 查询 输出 销售 查询 输出 按入 库单 按 日期 汇总 按 入库单 + 日期 按 供应商 汇总

3.省略代码设计和数据库设计,直接进行人机界面设计。画出界面图。

利用VB进行工程制作,其窗体与模块如图:

4.建立主模块。

在VB中新建工程后在工程资源管理器中单击鼠标右键建立模块,输入模块代码。 模块代码如下:

Option Explicit

Public conn As New ADODB.Connection '标记连接对象 Public userID As String '标记当前用户ID Public userpow As String '标记用户权限 Public find As Boolean '标记查询 Public sqlfind As String '查询语句 Public rs_data1 As New ADODB.Recordset Public findok As Boolean

Public summary_menu As String '标记汇总种类 Public frmdata As Boolean

Public Const keyenter = 13 'enter键的ASCII码

然后在VB工程中建立登陆窗体,共有14个窗体,要求建立出的窗体不能与所给范例完全一样。可自行设置个控件的摆放位置和色彩、字体等属性、添加图片按钮等以美化窗体。

例:添加“确定”图片按钮的方法: 自行设计或网络搜索“确定”图片素材; 将命令按钮COMMAND1的CAPTION属性设置为空; 将PICTURE属性设置为图片所在的路径; 将STYLE属性设置为1-Graphical。

5.写出完整菜单所包含的各菜单项、各子菜单项的标题和名称,用如下表格形式编写。

主菜单标题 信息维护 主菜单名称 xxwh 销售信息维护 xswh 子菜单标题 入库信息维护 子菜单名称 rkwh

入库管理 销售管理 incheck sale 无 无 增加新用户 系统管理 system 修改密码 退出系统 入库查询输出 查询管理 find 销售查询输出 按日期汇总 车辆汇总 clhz 按入库单 按入库单+日期

按供应商汇总 clwh 无 无 add_user modify_pw exit rkfind xsfind arqhz summary_custom summary_ruku summary_date_ruku 6.建立登陆窗体和其他窗体。代码见文本文件。理解代码的含义。在进行窗体建立时,将数据库和工程窗体放置于一个文件夹下,开始窗体的建立与代码的输入。

登陆窗体代码如下:

Option Explicit

Dim cnt As Integer '记录确定次数

Dim sql As String

Dim rs_login As New ADODB.Recordset

If Trim(txtuser.Text) = \判断输入的用户名是否为空 MsgBox \没有这个用户\ txtuser.SetFocus Else

sql = \系统管理 where 用户名='\ rs_login.Open sql, conn, adOpenKeyset, adLockPessimistic If rs_login.EOF = True Then

MsgBox \没有这个用户\ txtuser.SetFocus

Else '检验密码是否正确 If Trim(rs_login.Fields(1)) = Trim(txtpwd.Text) Then userID = txtuser.Text userpow = rs_login.Fields(2) rs_login.Close Unload Me MDIForm1.Show Else

MsgBox \密码不正确\ txtpwd.SetFocus End If End If End If cnt = cnt + 1 If cnt = 3 Then Unload Me End If Exit Sub End Sub

Private Sub Command2_Click() Unload Me End Sub

Private Sub Form_Load() Dim connectionstring As String

connectionstring = \ \conn.Open connectionstring cnt = 0

欢迎界面代码如下:

Private Sub add_user_Click() frmadduser.Show End Sub

Private Sub data_manage_Click() frmdatamanage.Show End Sub

Private Sub clwh_Click() frmcarfix.Show End Sub

Private Sub exit_Click() Dim s

s = MsgBox(\您确定要退出汽车销售系统吗?\If s = vbOK Then Unload Me End If End Sub

Private Sub rkfind_Click() frmfind_menu = \入库单\frmfind.Show End Sub

Private Sub xsfind_Click() frmxsfind_menu = \提货单\

End Sub

Private Sub incheck_Click() incheck1.Show End Sub

Private Sub modify_pw_Click() frmchangepwd.Show End Su

Private Sub rkwh_Click() frmrkfix.Show End Sub

Private Sub sale_Click() sale1.Show End Sub

Private Sub summary_custom_Click() summary_menu = \frmsum.Show 1 End Sub

Private Sub summary_date_Click() summary_menu = \frmsum.Show 1 End Sub

Private Sub summary_date_ruku_Click() summary_menu = \frmsum.Show 1 End Sub

Private Sub summary_ruku_Click() summary_menu = \frmsum.Show 1 End Sub

Private Sub xswh_Click() frmxsfix.Show End Sub

入库管理代码如下:

Option Explicit

Dim rs_checkname As New ADODB.Recordset '车辆名称对应的数据对象 Dim rs_custom As New ADODB.Recordset '供应商名称对应的数据对象 Const row_num = 10 '表格行数 Const col_num = 6 '表格列数 Private Sub Combo2_Click() MSFlexGrid1.Text = Combo2.Text MSFlexGrid1.Row = MSFlexGrid1.Row + 1 MSFlexGrid1.Col = 0 Combo2.Visible = False Text5.Visible = True

nextposition MSFlexGrid1.Row, MSFlexGrid1.Col End Sub

Private Sub Command1_Click() Dim rs_save As New ADODB.Recordset Dim sql As String Dim i As Integer

Dim s As String '转化数据用 On Error GoTo saveerror If Trim(Text1.Text) = \

MsgBox \入库单号不能为空!\ Text1.SetFocus

Exit Sub End If

If Combo1.Text = \请选择车辆名称\

MsgBox \请选择账目名!\ Combo1.SetFocus Exit Sub End If

If Comboy.Text = \

MsgBox \请选择年份!\ Comboy.SetFocus Exit Sub End If

If Combom.Text = \

MsgBox \请选择月份!\ Combom.SetFocus Exit Sub End If

If Combod.Text = \

MsgBox \请选择日期!\ Combod.SetFocus Exit Sub End If

If MSFlexGrid1.Col <> 0 Then

MsgBox \请输入完整的物品信息!\ Text5.SetFocus Exit Sub End If

sql = \入库单 where 入库单号='\rs_save.Open sql, conn, adOpenKeyset, adLockPessimistic If rs_save.EOF Then rs_save.AddNew

rs_save.Fields(0) = Trim(Text1.Text)

rs_save.Fields(1) = CDate(Trim(Comboy.Text) & \ rs_save.Fields(2) = Trim(Combo1.Text) rs_save.Fields(3) = Trim(Text2.Text) rs_save.Fields(4) = Trim(Text3.Text) rs_save.Fields(5) = Trim(Text4.Text) rs_save.Update rs_save.Close Else

MsgBox \入库单号重复!\ Text1.SetFocus Text1.Text = \ rs_save.Close Exit Sub End If

sql = \车辆资料\

rs_save.Open sql, conn, adOpenKeyset, adLockPessimistic For i = 1 To MSFlexGrid1.Row - 1 rs_save.AddNew

rs_save.Fields(0) = Trim(Text1.Text)

rs_save.Fields(1) = CDate(Trim(Comboy.Text) & \& Trim(Combom.Text) & \& Trim(Combod.Text)) rs_save.Fields(2) = Trim(Combo1.Text) MSFlexGrid1.Row = i MSFlexGrid1.Col = 0

rs_save.Fields(3) = Trim(MSFlexGrid1.Text) MSFlexGrid1.Col = 1

If incheck1.Caption = \出库\ s = \ rs_save.Fields(4) = CDbl(s) Else

rs_save.Fields(4) = CDbl(Trim(MSFlexGrid1.Text)) End If

MSFlexGrid1.Col = 2

rs_save.Fields(5) = Trim(MSFlexGrid1.Text) MSFlexGrid1.Col = 3

rs_save.Fields(6) = Trim(MSFlexGrid1.Text) MSFlexGrid1.Col = 4

If incheck1.Caption = \出库\ s = \ rs_save.Fields(7) = CDbl(s) Else

rs_save.Fields(7) = CDbl(Trim(MSFlexGrid1.Text)) End If

MSFlexGrid1.Col = 5

rs_save.Fields(8) = Trim(MSFlexGrid1.Text) Next i

rs_save.Update rs_save.Close

MsgBox \添加成功!\

Exit Sub saveerror:

MsgBox Err.Description End Sub

Private Sub Command2_Click() Unload Me End Sub

Private Sub Form_Load() Dim sql As String Dim i As Integer On Error GoTo loaderror sql = \车辆名称\

rs_checkname.CursorLocation = adUseClient

rs_checkname.Open sql, conn, adOpenKeyset, adLockPessimistic sql = \供应商名称\rs_custom.CursorLocation = adUseClient

rs_custom.Open sql, conn, adOpenKeyset, adLockPessimistic While Not rs_custom.EOF

Comboy.AddItem rs_custom.Fields(0) rs_custom.MoveNext Wend

If Not rs_checkname.EOF Then rs_checkname.MoveFirst

While Not rs_checkname.EOF '添加可选择的车辆名称 Combo1.AddItem rs_checkname.Fields(0) rs_checkname.MoveNext Wend End If

Comboy.AddItem 2000 '添加年份 Comboy.AddItem 2001 Comboy.AddItem 2002 Comboy.AddItem 2003

For i = 1 To 12 '添加月份 Combom.AddItem i Next i

For i = 1 To 31 '添加日期 Combod.AddItem i Next i setgrid

Text5.Visible = False clear_grid Exit Sub loaderror:

MsgBox Err.Description End Sub

Private Sub Form_Unload(Cancel As Integer) '关闭数据对象 rs_checkname.Close rs_custom.Close End Sub

Public Sub setgrid() '设置表格子程序 Dim i As Integer On Error GoTo seterror

MSFlexGrid1.ScrollBars = flexScrollBarBoth MSFlexGrid1.FixedCols = 0 MSFlexGrid1.Rows = row_num MSFlexGrid1.Cols = col_num

MSFlexGrid1.SelectionMode = flexSelectionByRow For i = 0 To row_num - 1

MSFlexGrid1.RowHeight(i) = 315 Next

For i = 0 To col_num - 1

MSFlexGrid1.ColWidth(i) = 1300 Next i Exit Sub seterror:

MsgBox Err.Description End Sub

Public Sub setgrid_head() On Error GoTo setheaderror MSFlexGrid1.Row = 0 MSFlexGrid1.Col = 0

MSFlexGrid1.Text = \车辆名称\MSFlexGrid1.Col = 1

MSFlexGrid1.Text = \单价\MSFlexGrid1.Col = 2 MSFlexGrid1.Text = \数量\MSFlexGrid1.Col = 3

单位\

MSFlexGrid1.Col = 4

MSFlexGrid1.Text = \金额\MSFlexGrid1.Col = 5

MSFlexGrid1.Text = \供应商名称\Exit Sub setheaderror:

MsgBox Err.Description End Sub

Public Sub clear_grid() Dim i As Integer, j As Integer For i = 1 To row_num - 1 MSFlexGrid1.Row = i For j = 0 To col_num - 1 MSFlexGrid1.Col = j MSFlexGrid1.Text = \ Next j Next i End Sub

Public Sub nextposition(ByVal r As Integer, ByVal c As Integer) On Error GoTo nexterror

Text5.Width = MSFlexGrid1.CellWidth Text5.Height = MSFlexGrid1.CellHeight

Text5.Left = MSFlexGrid1.Left + MSFlexGrid1.ColPos(c) Text5.Top = MSFlexGrid1.Top + MSFlexGrid1.RowPos(r) Text5.Text = MSFlexGrid1.Text Text5.Visible = True Text5.SetFocus Exit Sub nexterror:

MsgBox Err.Description End Sub

Private Sub MSFlexGrid1_Click() If Combo2.Visible = True Then Exit Sub End If

nextposition MSFlexGrid1.Row, MSFlexGrid1.Col End Sub

Private Sub Text5_KeyPress(KeyAscii As Integer) Dim i As Integer, j As Integer

On Error GoTo texterror If KeyAscii = keyenter Then MSFlexGrid1.Text = Text5.Text i = MSFlexGrid1.Row j = MSFlexGrid1.Col

If j = 0 And Trim(Text5.Text) = \

MsgBox \车辆名称不能为空\ Text5.SetFocus Exit Sub End If

If j = 1 And Not IsNumeric(Text5.Text) Then

MsgBox \单价请输入数字!\ Text5.SetFocus Exit Sub End If

If j = 2 And Not IsNumeric(Text5.Text) Then

MsgBox \数量请输入数字!\ Text5.SetFocus Exit Sub End If

If j = 3 And Trim(Text5.Text) = \

MsgBox \单位不能为空!\ Text5.SetFocus Exit Sub End If

If j = 3 And Not IsNull(Text5.Text) Then

MSFlexGrid1.Col = 1 '金额由程序算出 price = CDbl(MSFlexGrid1.Text) MSFlexGrid1.Col = 2

coun = CInt(MSFlexGrid1.Text) MSFlexGrid1.Col = 4

MSFlexGrid1.Text = price * coun MSFlexGrid1.Col = MSFlexGrid1.Col + 1 Text5.Visible = False

setcombo2 MSFlexGrid1.Row, MSFlexGrid1.Col KeyAscii = 0 Exit Sub End If

MSFlexGrid1.Col = MSFlexGrid1.Col + 1

nextposition MSFlexGrid1.Row, MSFlexGrid1.Col End If Exit Sub texterror:

MsgBox Err.Description End Sub

Public Sub setcombo2(ByVal r As Integer, ByVal c As Integer) On Error GoTo seterror

Combo2.Width = MSFlexGrid1.CellWidth

Combo2.Left = MSFlexGrid1.Left + MSFlexGrid1.ColPos(c) Combo2.Top = MSFlexGrid1.Top + MSFlexGrid1.RowPos(r) Combo2.Text = MSFlexGrid1.Text Combo2.Visible = True Combo2.SetFocus Exit Sub seterror:

MsgBox Err.Description End Sub

销售管理代码如下:

Option Explicit

Dim rs_checkname As New ADODB.Recordset

Const row_num = 10 '表格行数 Const col_num = 6 '表格列数 Private Sub Combo1_Click() MSFlexGrid1.Text = Combo1.Text MSFlexGrid1.Row = MSFlexGrid1.Row + 1 MSFlexGrid1.Col = 0 Combo1.Visible = False Text5.Visible = True

nextposition MSFlexGrid1.Row, MSFlexGrid1.Col End Sub

Private Sub Command1_Click() Dim rs_save As New ADODB.Recordset Dim sql As String Dim i As Integer

Dim s As String '转化数据用 On Error GoTo saveerror If Trim(Text1.Text) = \

MsgBox \提货单号不能为空!\ Text1.SetFocus Exit Sub End If

If Combo1.Text = \请选择车辆名称\

MsgBox \请选择车辆名称!\ Combo1.SetFocus Exit Sub End If

If Comboy.Text = \

MsgBox \请选择年份!\ Comboy.SetFocus Exit Sub End If

If Combom.Text = \

MsgBox \请选择月份!\ Combom.SetFocus Exit Sub End If

If Combod.Text = \

MsgBox \请选择日期!\ Combod.SetFocus

Exit Sub End If

If MSFlexGrid1.Col <> 0 Then

MsgBox \请输入完整的物品信息!\ Text5.SetFocus Exit Sub End If

sql = \销售单 where 提货单号='\rs_save.Open sql, conn, adOpenKeyset, adLockPessimistic If rs_save.EOF Then rs_save.AddNew

rs_save.Fields(0) = Trim(Text1.Text)

rs_save.Fields(1) = CDate(Trim(Comboy.Text) & \ rs_save.Fields(2) = Trim(Combo1.Text) rs_save.Fields(3) = Trim(Text2.Text) rs_save.Fields(4) = Trim(Text3.Text) rs_save.Fields(5) = Trim(Text4.Text) rs_save.Update rs_save.Close Else

MsgBox \提货单号重复!\ Text1.SetFocus Text1.Text = \ rs_save.Close Exit Sub End If

sql = \车辆资料\

rs_save.Open sql, conn, adOpenKeyset, adLockPessimistic For i = 1 To MSFlexGrid1.Row - 1 rs_save.AddNew

rs_save.Fields(0) = Trim(Text1.Text)

rs_save.Fields(1) = CDate(Trim(Comboy.Text) & \& Trim(Combom.Text) & \& Trim(Combod.Text)) rs_save.Fields(2) = Trim(Combo1.Text) MSFlexGrid1.Row = i MSFlexGrid1.Col = 0

rs_save.Fields(3) = Trim(MSFlexGrid1.Text) MSFlexGrid1.Col = 1 MSFlexGrid1.Col = 2

rs_save.Fields(5) = Trim(MSFlexGrid1.Text) MSFlexGrid1.Col = 3

rs_save.Fields(6) = Trim(MSFlexGrid1.Text) MSFlexGrid1.Col = 4 MSFlexGrid1.Col = 5

rs_save.Fields(8) = Trim(MSFlexGrid1.Text) Next i

rs_save.Update rs_save.Close

MsgBox \添加成功!\Unload Me Exit Sub saveerror:

MsgBox Err.Description End Sub

Private Sub Command2_Click() Unload Me End Sub

Private Sub Form_Load() Dim sql As String Dim i As Integer On Error GoTo loaderror sql = \车辆名称\

rs_checkname.CursorLocation = adUseClient

rs_checkname.Open sql, conn, adOpenKeyset, adLockPessimistic sql = \供应商名称\rs_custom.CursorLocation = adUseClient

rs_custom.Open sql, conn, adOpenKeyset, adLockPessimistic While Not rs_custom.EOF

Combo1.AddItem rs_custom.Fields(0) rs_custom.MoveNext Wend

If Not rs_checkname.EOF Then rs_checkname.MoveFirst

While Not rs_checkname.EOF '添加可选择的发货地 Combo1.AddItem rs_checkname.Fields(0) rs_checkname.MoveNext Wend End If

Comboy.AddItem 2002 '添加年份 Comboy.AddItem 2003 Comboy.AddItem 2004

For i = 1 To 12 '添加月份 Combom.AddItem i Next i

For i = 1 To 31 '添加日期 Combod.AddItem i Next i setgrid setgrid_head

Text5.Visible = False clear_grid Exit Sub loaderror:

MsgBox Err.Description End Sub

Private Sub Form_Unload(Cancel As Integer) '关闭数据对象 rs_checkname.Close rs_custom.Close End Sub

Public Sub setgrid() '设置表格子程序 Dim i As Integer On Error GoTo seterror

MSFlexGrid1.ScrollBars = flexScrollBarBoth MSFlexGrid1.FixedCols = 0 MSFlexGrid1.Rows = row_num MSFlexGrid1.Cols = col_num

MSFlexGrid1.SelectionMode = flexSelectionByRow For i = 0 To row_num - 1

MSFlexGrid1.RowHeight(i) = 315 Next

For i = 0 To col_num - 1

MSFlexGrid1.ColWidth(i) = 1300 Next i Exit Sub seterror:

MsgBox Err.Description End Sub

Public Sub setgrid_head() On Error GoTo setheaderror

MSFlexGrid1.Col = 0

MSFlexGrid1.Text = \车辆名称\MSFlexGrid1.Col = 1

MSFlexGrid1.Text = \单价\MSFlexGrid1.Col = 2 MSFlexGrid1.Text = \数量\MSFlexGrid1.Col = 3 MSFlexGrid1.Text = \单位\MSFlexGrid1.Col = 4

MSFlexGrid1.Text = \金额\MSFlexGrid1.Col = 5

MSFlexGrid1.Text = \供应商名称\Exit Sub setheaderror:

MsgBox Err.Description End Sub

Public Sub clear_grid() Dim i As Integer, j As Integer For i = 1 To row_num - 1 MSFlexGrid1.Row = i For j = 0 To col_num - 1 MSFlexGrid1.Col = j MSFlexGrid1.Text = \ Next j Next i End Sub

Public Sub nextposition(ByVal r As Integer, ByVal c As Integer) On Error GoTo nexterror

Text5.Width = MSFlexGrid1.CellWidth Text5.Height = MSFlexGrid1.CellHeight

Text5.Left = MSFlexGrid1.Left + MSFlexGrid1.ColPos(c) Text5.Top = MSFlexGrid1.Top + MSFlexGrid1.RowPos(r) Text5.Text = MSFlexGrid1.Text Text5.Visible = True Text5.SetFocus Exit Sub nexterror:

MsgBox Err.Description End Sub

If Combo1.Visible = True Then Exit Sub End If

nextposition MSFlexGrid1.Row, MSFlexGrid1.Col End Sub

Private Sub Text5_KeyPress(KeyAscii As Integer) Dim i As Integer, j As Integer Dim price As Double, coun As Integer On Error GoTo texterror If KeyAscii = keyenter Then MSFlexGrid1.Text = Text5.Text i = MSFlexGrid1.Row j = MSFlexGrid1.Col

If j = 0 And Trim(Text5.Text) = \

MsgBox \车辆名称不能为空\ Text5.SetFocus Exit Sub End If

If j = 1 And Not IsNumeric(Text5.Text) Then

MsgBox \单价请输入数字!\ Text5.SetFocus Exit Sub End If

If j = 2 And Not IsNumeric(Text5.Text) Then

MsgBox \数量请输入数字!\ Text5.SetFocus Exit Sub End If

If j = 3 And Trim(Text5.Text) = \

MsgBox \单位不能为空!\ Text5.SetFocus Exit Sub End If

If j = 3 And Not IsNull(Text5.Text) Then

MSFlexGrid1.Col = 1 '金额由程序算出 price = CDbl(MSFlexGrid1.Text) MSFlexGrid1.Col = 2

coun = CInt(MSFlexGrid1.Text) MSFlexGrid1.Col = 4

MSFlexGrid1.Text = price * coun

MSFlexGrid1.Col = MSFlexGrid1.Col + 1 Text5.Visible = False

setcombo2 MSFlexGrid1.Row, MSFlexGrid1.Col KeyAscii = 0 Exit Sub End If

MSFlexGrid1.Col = MSFlexGrid1.Col + 1 KeyAscii = 0

nextposition MSFlexGrid1.Row, MSFlexGrid1.Col End If Exit Sub texterror:

MsgBox Err.Description End Sub

Public Sub setcombo2(ByVal r As Integer, ByVal c As Integer) On Error GoTo seterror

Combo1.Width = MSFlexGrid1.CellWidth

Combo1.Left = MSFlexGrid1.Left + MSFlexGrid1.ColPos(c) Combo1.Top = MSFlexGrid1.Top + MSFlexGrid1.RowPos(r) Combo1.Text = MSFlexGrid1.Text Combo1.Visible = True Combo1.SetFocus Exit Sub seterror:

MsgBox Err.Description End Sub

增加用户代码如下:

Private Sub Command1_Click() Dim sql As String

Dim rs_add As New ADODB.Recordset If Trim(Text1.Text) = \

MsgBox \用户名不能为空\ Exit Sub Text1.SetFocus Else

sql = \系统管理\

rs_add.Open sql, conn, adOpenKeyset, adLockPessimistic While (rs_add.EOF = False)

If Trim(rs_add.Fields(0)) = Trim(Text1.Text) Then MsgBox \已有这个用户\ Text1.SetFocus Text1.Text = \ Text2.Text = \ Text3.Text = \ Combo1.Text = \ Exit Sub Else

rs_add.MoveNext End If Wend

If Trim(Text2.Text) = \

MsgBox \密码不能为空,请重新输入!\警告\ Text2.Text = \ Text2.SetFocus Exit Sub End If

If Trim(Text2.Text) <> Trim(Text3.Text) Then

MsgBox \两次密码不一致\ Text2.SetFocus Text2.Text = \ Text3.Text = \ Exit Sub

ElseIf Trim(Combo1.Text) <> \ MsgBox \请选择正确的用户权限\ Combo1.SetFocus Combo1.Text = \ Exit Sub Else

rs_add.AddNew

rs_add.Fields(0) = Text1.Text rs_add.Fields(1) = Text2.Text rs_add.Fields(2) = Combo1.Text rs_add.Update rs_add.Close

MsgBox \添加用户成功\ Unload Me End If End If End Sub

Private Sub Command2_Click() Unload Me End Sub

Private Sub Form_Load() Combo1.AddItem \Combo1.AddItem \End Sub

修改密码代码如下:

Private Sub Command1_Click() Dim rs_chang As New ADODB.Recordset Dim sql As String

If Trim(Text1.Text) <> Trim(Text2.Text) Then

MsgBox \密码不一致!\ Text1.SetFocus Text1.Text = \ Text2.Text = \Else

sql = \系统管理 where 用户名='\ rs_chang.Open sql, conn, adOpenKeyset, adLockPessimistic rs_chang.Fields(1) = Text1.Text rs_chang.Update rs_chang.Close

MsgBox \密码修改成功\ Unload Me End If End Sub

Private Sub Command2_Click() Unload Me End Sub

Private Sub Form_Load()

End Sub

入库查询输出代码如下:

Option Explicit

Dim rs_find As New ADODB.Recordset Private Sub Command1_Click() On Error GoTo cmderror Dim find_date1 As String Dim find_date2 As String If Option1.Value = True Then

sqlfind = \入库单 where 入库单号 between '\ Combo1(0).Text & \End If

If Option2.Value = True Then

find_date1 = Format(CDate(Comboy(0).Text & \ Combom(0).Text & \ find_date2 = Format(CDate(Comboy(1).Text & \ Combom(1).Text & \ sqlfind = \入库单 where 日期 between #\ find_date1 & \End If

rs_data1.Open sqlfind, conn, adOpenKeyset, adLockPessimistic frmdatamanage.Show

frmdatamanage.displaygrid1 Unload Me

If Err.Number <> 0 Then

MsgBox \请输入正确的查询条件!\警告\ End If End Sub

Private Sub Command2_Click() Unload Me MDIForm1.Show End Sub

Private Sub Form_Load() Dim i As Integer Dim sql As String Option1.Value = True If findok = True Then rs_data1.Close End If

sql = \入库单 order by 入库单号 desc\rs_find.CursorLocation = adUseClient

rs_find.Open sql, conn, adOpenKeyset, adLockPessimistic If rs_find.EOF = False Then '添加编号 With rs_find

Do While Not .EOF

Combo1(0).AddItem .Fields(0) Combo1(1).AddItem .Fields(0) .MoveNext Loop End With End If

For i = 2001 To 2005 '添加年 Comboy(0).AddItem i Comboy(1).AddItem i Next i

For i = 1 To 12 '添加月 Combom(0).AddItem i Combom(1).AddItem i Next i

For i = 1 To 31 '添加日 Combod(0).AddItem i Combod(1).AddItem i Next i

Private Sub Form_Unload(Cancel As Integer) rs_find.Close End Sub

销售查询输出代码如下:

Option Explicit

Dim rs_find As New ADODB.Recordset Private Sub Command1_Click() On Error GoTo cmderror Dim find_date1 As String Dim find_date2 As String If Option1.Value = True Then

sqlfind = \销售单 where 提货单号 between '\ Combo1(0).Text & \End If

If Option2.Value = True Then

find_date1 = Format(CDate(Comboy(0).Text & \ Combom(0).Text & \ find_date2 = Format(CDate(Comboy(1).Text & \ Combom(1).Text & \ sqlfind = \销售单 where 日期 between #\ find_date1 & \End If

rs_data1.Open sqlfind, conn, adOpenKeyset, adLockPessimistic frmdataxsmanage.Show

splaygrid1

Unload Me cmderror:

If Err.Number <> 0 Then

MsgBox \请输入正确的查询条件!\警告\ End If End Sub

Private Sub Command2_Click() Unload Me MDIForm1.Show End Sub

Private Sub Form_Load() Dim i As Integer Dim sql As String Option1.Value = True If findok = True Then rs_data1.Close End If

sql = \销售单 order by 提货单号 desc\rs_find.CursorLocation = adUseClient

rs_find.Open sql, conn, adOpenKeyset, adLockPessimistic If rs_find.EOF = False Then '添加编号 With rs_find

Do While Not .EOF

Combo1(0).AddItem .Fields(0) Combo1(1).AddItem .Fields(0) .MoveNext Loop End With End If

For i = 2001 To 2005 '添加年 Comboy(0).AddItem i Comboy(1).AddItem i Next i

For i = 1 To 12 '添加月 Combom(0).AddItem i Combom(1).AddItem i Next i

For i = 1 To 31 '添加日

Combod(0).AddItem i Combod(1).AddItem i Next i End Sub

Private Sub Form_Unload(Cancel As Integer) rs_find.Close End Sub

库存资料代码如下:

Option Explicit

Dim rs_data2 As New ADODB.Recordset Dim select_row As String Dim showgrid2 As Boolean

Dim rs_custom As New ADODB.Recordset

Dim jinchu As String '进出库标志 Dim modify As Boolean '修改状态标志

Private Sub Command1_Click() Unload Me End Sub

Private Sub Form_Load() On Error GoTo loaderror Dim sql As String

displaygrid1 '调用显示displaygrid1子程序 loaderror:

If Err.Number <> 0 Then MsgBox Err.Description End If End Sub

'显示msflexgrid1子程序 Public Sub displaygrid1() Dim i As Integer

On Error GoTo displayerror setgrid setgridhead

MSFlexGrid1.Row = 0 If Not rs_data1.EOF Then rs_data1.MoveFirst Do While Not rs_data1.EOF

MSFlexGrid1.Row = MSFlexGrid1.Row + 1 MSFlexGrid1.Col = 0

If Not IsNull(rs_data1.Fields(0)) Then MSFlexGrid1.Text = rs_data1.Fields(0) Else MSFlexGrid1.Text = \

MSFlexGrid1.Col = 1

If Not IsNull(rs_data1.Fields(1)) Then MSFlexGrid1.Text = rs_data1.Fields(1) Else MSFlexGrid1.Text = \

MSFlexGrid1.Col = 2

If Not IsNull(rs_data1.Fields(2)) Then MSFlexGrid1.Text = rs_data1.Fields(2) Else MSFlexGrid1.Text = \

MSFlexGrid1.Col = 3

If Not IsNull(rs_data1.Fields(3)) Then MSFlexGrid1.Text = rs_data1.Fields(3) Else MSFlexGrid1.Text = \

MSFlexGrid1.Col = 4

If Not IsNull(rs_data1.Fields(4)) Then MSFlexGrid1.Text = rs_data1.Fields(4) Else MSFlexGrid1.Text = \

MSFlexGrid1.Col = 5

If Not IsNull(rs_data1.Fields(5)) Then MSFlexGrid1.Text = rs_data1.Fields(5) Else MSFlexGrid1.Text = \

MSFlexGrid1.Col = 6

If rs_data1.Fields(6) = True Then MSFlexGrid1.Text = \进库\出库\

rs_data1.MoveNext

Loop End If displayerror:

If Err.Number <> 0 Then MsgBox Err.Description End If End Sub

Public Sub setgrid() Dim i As Integer On Error GoTo seterror With MSFlexGrid1

.ScrollBars = flexScrollBarBoth .FixedCols = 0

.Rows = rs_data1.RecordCount + 1 .Cols = 7

.SelectionMode = flexSelectionByRow For i = 0 To .Rows - 1 .RowHeight(i) = 315 Next

For i = 0 To .Cols - 1 .ColWidth(i) = 1300 Next i End With Exit Sub seterror:

MsgBox Err.Description End Sub

Public Sub setgridhead() On Error GoTo setheaderror MSFlexGrid1.Row = 0 MSFlexGrid1.Col = 0

MSFlexGrid1.Text = \入库单号\MSFlexGrid1.Col = 1 MSFlexGrid1.Text = \日期\MSFlexGrid1.Col = 2

MSFlexGrid1.Text = \车辆名称\MSFlexGrid1.Col = 3

MSFlexGrid1.Text = \库存位号\

MSFlexGrid1.Text = \入库数量\MSFlexGrid1.Col = 5

MSFlexGrid1.Text = \经手人\MSFlexGrid1.Col = 6

MSFlexGrid1.Text = \进出库\Exit Sub setheaderror:

MsgBox Err.Description End Sub

Private Sub Form_Unload(Cancel As Integer) findok = False rs_data1.Close

If showgrid2 = True Then rs_data2.Close End If End Sub

销售信息代码如下:

Option Explicit

Dim rs_data2 As New ADODB.Recordset Dim select_row As String Dim showgrid2 As Boolean

Dim rs_custom As New ADODB.Recordset

Dim jinchu As String '进出库标志

修改状态标志

Private Sub Command1_Click() Unload Me End Sub

Private Sub Form_Load() On Error GoTo loaderror Dim sql As String

displaygrid1 '调用显示displaygrid1子程序 loaderror:

If Err.Number <> 0 Then MsgBox Err.Description End If End Sub

'显示msflexgrid1子程序 Public Sub displaygrid1() Dim i As Integer

On Error GoTo displayerror setgrid setgridhead

MSFlexGrid1.Row = 0 If Not rs_data1.EOF Then rs_data1.MoveFirst Do While Not rs_data1.EOF

MSFlexGrid1.Row = MSFlexGrid1.Row + 1 MSFlexGrid1.Col = 0

If Not IsNull(rs_data1.Fields(0)) Then MSFlexGrid1.Text = rs_data1.Fields(0) Else MSFlexGrid1.Text = \

MSFlexGrid1.Col = 1

If Not IsNull(rs_data1.Fields(1)) Then MSFlexGrid1.Text = rs_data1.Fields(1) Else MSFlexGrid1.Text = \

MSFlexGrid1.Col = 2

If Not IsNull(rs_data1.Fields(2)) Then MSFlexGrid1.Text = rs_data1.Fields(2) Else MSFlexGrid1.Text = \

MSFlexGrid1.Col = 3

If Not IsNull(rs_data1.Fields(3)) Then MSFlexGrid1.Text = rs_data1.Fields(3) Else MSFlexGrid1.Text = \

MSFlexGrid1.Col = 4

If Not IsNull(rs_data1.Fields(4)) Then MSFlexGrid1.Text = rs_data1.Fields(4) Else

MSFlexGrid1.Text = \

MSFlexGrid1.Col = 5

If Not IsNull(rs_data1.Fields(5)) Then MSFlexGrid1.Text = rs_data1.Fields(5) Else MSFlexGrid1.Text = \

MSFlexGrid1.Col = 6

If rs_data1.Fields(6) = True Then MSFlexGrid1.Text = \进库\出库\

rs_data1.MoveNext Loop End If displayerror:

If Err.Number <> 0 Then MsgBox Err.Description End If End Sub

Public Sub setgrid() Dim i As Integer On Error GoTo seterror With MSFlexGrid1

.ScrollBars = flexScrollBarBoth .FixedCols = 0

.Rows = rs_data1.RecordCount + 1 .Cols = 7

.SelectionMode = flexSelectionByRow For i = 0 To .Rows - 1 .RowHeight(i) = 315 Next

For i = 0 To .Cols - 1 .ColWidth(i) = 1300 Next i End With Exit Sub seterror:

MsgBox Err.Description End Sub

Public Sub setgridhead() On Error GoTo setheaderror

MSFlexGrid1.Col = 0

MSFlexGrid1.Text = \提货单号\MSFlexGrid1.Col = 1 MSFlexGrid1.Text = \日期\MSFlexGrid1.Col = 2

MSFlexGrid1.Text = \车辆名称\MSFlexGrid1.Col = 3

MSFlexGrid1.Text = \库存位号\MSFlexGrid1.Col = 4

MSFlexGrid1.Text = \经手人\MSFlexGrid1.Col = 5 MSFlexGrid1.Text = \备注\MSFlexGrid1.Col = 6

MSFlexGrid1.Text = \进出库\Exit Sub setheaderror:

MsgBox Err.Description End Sub

Private Sub Form_Unload(Cancel As Integer) findok = False rs_data1.Close

If showgrid2 = True Then rs_data2.Close End If End Sub

汇总代码如下:

Option Explicit

Dim rs_sum As New ADODB.Recordset Dim addup As Double

Private Sub Form_Load() Dim sql As String Select Case summary_menu

Case \按入库单号汇总 Label1.Caption = \按入库单号汇总\

本文来源:https://www.bwwdw.com/article/ql43.html

Top