论文无忧网提供:计算机毕业论文范文|计算机毕业设计|计算机毕业论文
栏目导航 ASP Java Web .NET VB6.0 JAVA VC VF DELPHI PB 计算机网络 计算机科学与技术 PHP 安卓APP 其他 C# 代写论文
当前位置: > 计算机 > VB6.0 >

A400201AC售楼管理系统

下面编辑各个按钮的功能。

(6)双击cmdAdd控件,在cmdAdd_Click事件中处理对该按钮的响应。 paper51.com

这个按钮有两个状态,分别是“增加”和“保存”。首先应该判断当前按钮的状态。 copyright paper51.com

如果当前的按钮状态为“增加”,则窗体各部分接受新的数据输入。此时清空所有的文本框的内容,同时将“修改”和“删除”按钮设置为不可用。 内容来自www.paper51.com

Private Sub cmdadd_Click() paper51.com

    OnError GoTo adderror

内容来自www.paper51.com

    IfcmdAdd.Caption = "保  存"Then

内容来自www.paper51.com

       '下面对输入的有效性进行验证 http://www.paper51.com

       If Trim(txtHuxingnum.Text) = "" Then paper51.com

 MsgBox "户型编号不能为空!",vbOKOnly + vbExclamation, ""

paper51.com

          txtHuxingnum.SetFocus 内容来自www.paper51.com

          Exit Sub copyright paper51.com

       End If

内容来自论文无忧网 www.paper51.com

       If Trim(txtFangxing.Text) = "" Then copyright paper51.com

      MsgBox "请选择房型!",vbOKOnly + vbExclamation, " "

http://www.paper51.com

          Combo1.SetFocus

copyright paper51.com

          Exit Sub copyright paper51.com

       End If

copyright paper51.com

       If Trim(txtJianzhumianji.Text) = "" Then

paper51.com

 MsgBox "建筑面积不能为空!",vbOKOnly + vbExclamation, " " copyright paper51.com

          txtJianzhumianji.SetFocus 内容来自论文无忧网 www.paper51.com

          Exit Sub

copyright paper51.com

       End If

内容来自www.paper51.com

       If Trim(txtTaomianji.Text) = "" Then http://www.paper51.com

 MsgBox "套内面积不能为空!",vbOKOnly + vbExclamation, " " 内容来自论文无忧网 www.paper51.com

          txtTaomianji.SetFocus paper51.com

          Exit Sub paper51.com

       End If

内容来自www.paper51.com

 IfNot IsNumeric(txtJianzhumianji.Text) Then '面积必须是数值 paper51.com

MsgBox "建筑面积请输入数字!",vbOKOnly + vbExclamation, "" 内容来自论文无忧网 www.paper51.com

             txtJianzhumianji.SetFocus paper51.com

             Exit Sub 内容来自www.paper51.com

       End If http://www.paper51.com

       If Not IsNumeric(txtTaomianji.Text) Then paper51.com

 MsgBox "套内面积请输入数字!",vbOKOnly + vbExclamation, "" paper51.com

             txtTaomianji.SetFocus

http://www.paper51.com

             Exit Sub

内容来自www.paper51.com

       End If 内容来自论文无忧网 www.paper51.com

       http://www.paper51.com

如果当前按钮的状态为“保存”状态,则需要将新添加的数据写进数据库。 内容来自www.paper51.com

首先应当判断各项内容是否已经正确输入,如果没有正确输入则给出提示,并退出过程。 内容来自www.paper51.com

On Error GoTo adderror

copyright paper51.com

    IfcmdAdd.Caption = "保  存"Then http://www.paper51.com

       '下面对输入的有效性进行验证 内容来自论文无忧网 www.paper51.com

       If Trim(txtHuxingnum.Text) = "" Then 内容来自论文无忧网 www.paper51.com

          MsgBox "户型编号不能为空!",vbOKOnly + vbExclamation, "" http://www.paper51.com

          txtHuxingnum.SetFocus

paper51.com

          Exit Sub paper51.com

       End If

内容来自www.paper51.com

       If Trim(txtFangxing.Text) = "" Then

内容来自论文无忧网 www.paper51.com

      MsgBox "请选择房型!",vbOKOnly + vbExclamation, " " copyright paper51.com

          Combo1.SetFocus 内容来自论文无忧网 www.paper51.com

          Exit Sub 内容来自www.paper51.com

       End If copyright paper51.com

       If Trim(txtJianzhumianji.Text) = "" Then copyright paper51.com

          MsgBox "建筑面积不能为空!",vbOKOnly + vbExclamation, " " 内容来自www.paper51.com

          txtJianzhumianji.SetFocus 内容来自论文无忧网 www.paper51.com

          Exit Sub http://www.paper51.com

       End If http://www.paper51.com

       If Trim(txtTaomianji.Text) = "" Then

内容来自论文无忧网 www.paper51.com

          MsgBox "套内面积不能为空!",vbOKOnly + vbExclamation, " " 内容来自论文无忧网 www.paper51.com

          txtTaomianji.SetFocus

paper51.com

          Exit Sub copyright paper51.com

       End If http://www.paper51.com

       If Not IsNumeric(txtJianzhumianji.Text) Then  '面积必须是数值 http://www.paper51.com

             MsgBox "建筑面积请输入数字!",vbOKOnly + vbExclamation, "" paper51.com

             txtJianzhumianji.SetFocus http://www.paper51.com

              Exit Sub

copyright paper51.com

       End If http://www.paper51.com

       If Not IsNumeric(txtTaomianji.Text) Then copyright paper51.com

             MsgBox "套内面积请输入数字!",vbOKOnly + vbExclamation, ""

paper51.com

             txtTaomianji.SetFocus

http://www.paper51.com

             Exit Sub

内容来自论文无忧网 www.paper51.com

       End If 内容来自论文无忧网 www.paper51.com

如果所有的数据都输入无误,则检查是否有重复的户型编号,如果有重复则给出提示,并退出过程。 http://www.paper51.com

 rs_huxing.MoveFirst              '输入合法,开始插入 copyright paper51.com

       Dim i As Integer 内容来自论文无忧网 www.paper51.com

  Fori = 0 To rs_huxing.RecordCount - 1   '逐条检查户型编号是否已经存在

内容来自www.paper51.com

 IfTrim(rs_huxing.Fields(0)) = Trim(txtHuxingnum.Text) Then

内容来自www.paper51.com

  MsgBox "户型编号重复!",vbOKOnly + vbExclamation, " "

内容来自论文无忧网 www.paper51.com

               txtHuxingnum.SetFocus

内容来自论文无忧网 www.paper51.com

               Exit Sub 内容来自论文无忧网 www.paper51.com

           End If

http://www.paper51.com

           rs_huxing.MoveNext http://www.paper51.com

       Next i

内容来自www.paper51.com

如果没有重复,则将新的数据添加到数据库中。注意,数据库中的字段格式应该和即将添加的数据格式一致。添加完毕后使用Update方法更新数据库。

copyright paper51.com

  rs_huxing.MoveLast     '户型编号不存在,在最后插入新纪录 内容来自www.paper51.com

       rs_huxing.AddNew

内容来自论文无忧网 www.paper51.com

 rs_huxing.Fields(0) =Trim(txtHuxingnum.Text)      '逐字段插入 paper51.com

 rs_huxing.Fields(1) =CSng(txtJianzhumianji.Text) '数值转换为字符串

http://www.paper51.com

       rs_huxing.Fields(2) = CSng(txtTaomianji.Text)

copyright paper51.com

       rs_huxing.Fields(3) = Trim(txtFangxing.Text) 内容来自论文无忧网 www.paper51.com

       rs_huxing.Fields(4) = Trim(txtJianjie.Text) paper51.com

       rs_huxing.Fields(5) = Trim(txtHuxingnum.Text) 内容来自www.paper51.com

       rs_huxing.Update                                '将插入的记录保存 内容来自www.paper51.com

       MsgBox "添加成功!",vbOKOnly + vbExclamation, "" 内容来自论文无忧网 www.paper51.com

同时需要更新表格控件的内容,将新的数据添加到表格中。

paper51.com

With grdHuxing             '将表格最后一行数据更新 内容来自www.paper51.com

            .Rows = rs_huxing.RecordCount + 1

内容来自www.paper51.com

            .Row = grdHuxing.Rows - 1 http://www.paper51.com

            .Col = 0

内容来自论文无忧网 www.paper51.com

            .Text = Trim(txtHuxingnum.Text)

内容来自www.paper51.com

            .Col = 1 copyright paper51.com

            .Text = Trim(txtJianzhumianji.Text)

paper51.com

            .Col = 2 内容来自论文无忧网 www.paper51.com

            .Text = Trim(txtTaomianji.Text) http://www.paper51.com

            .Col = 3 内容来自论文无忧网 www.paper51.com

            .Text = Trim(txtFangxing.Text)

http://www.paper51.com

            .Col = 4

http://www.paper51.com

            .Text = Trim(txtFangxing.Text) copyright paper51.com

            .Col = 5

http://www.paper51.com

            .Text = Trim(txtJianjie.Text) copyright paper51.com

       End With

http://www.paper51.com

 cmdAdd.Caption = "增  加"  '成功保存后标题变为“增  加”

copyright paper51.com

   Else                    '按钮标题为"增  加"时 paper51.com

       txtHuxingnum.Text = ""     '各个字段为空

内容来自论文无忧网 www.paper51.com

       txtJianzhumianji.Text = "" paper51.com

       txtTaomianji.Text = ""

copyright paper51.com

       txtJianjie.Text = ""

内容来自www.paper51.com

 cmdModify.Enabled = False   '新增记录时,不能修改和删除记录 paper51.com

       cmdDel.Enabled = False

内容来自论文无忧网 www.paper51.com

 cmdAdd.Caption = "保  存"          '按钮标题变为“保  存” copyright paper51.com

   End If

http://www.paper51.com

   Exit Sub paper51.com

adderror:

内容来自论文无忧网 www.paper51.com

      MsgBox Err.Description

内容来自论文无忧网 www.paper51.com

End Sub

内容来自论文无忧网 www.paper51.com

4.3.2建立楼盘登记窗体(frmBuildingLogin)

http://www.paper51.com

这个窗体主要用来对楼盘资料进行登记,包括添加、修改、删除等各种操作。 copyright paper51.com

1、界面设计

http://www.paper51.com

与设计户型登记窗体相似,在工程中添加一个窗体,命名为frmBuildingLogin。设置好控件及属性的frmBuildingLogin窗体如图6所示。 内容来自论文无忧网 www.paper51.com

内容来自www.paper51.com

图6 “楼盘登记”窗体效果图

paper51.com

2、工程流程

copyright paper51.com

窗体加载使用ADO进行数据库的连接,同时在表格中显示出数据。 内容来自论文无忧网 www.paper51.com

单击“增加”按钮时,所有的文本框为可用状态,并且设置为空,“增加”按钮变为“保存”按钮。在输入完新信息后,单击“保存”按钮,判断楼盘编号是否重复,对于不重复的楼盘进行入库保存。 copyright paper51.com

单击“删除”按钮时,首先询问是否确定要删除该信息,在得到确认后取得用户选定的楼盘信息,根据户型编号进行删除。 内容来自www.paper51.com

单击“修改”按钮时,所有的文本框进入可编辑状态,修改按钮变为保存按钮。修改后,单击“保存”按钮,进行数据的更新。

copyright paper51.com

3、添加代码 内容来自论文无忧网 www.paper51.com

(1)“增加”按钮的“Click”事件代码

内容来自论文无忧网 www.paper51.com

Private Sub cmdadd_Click() http://www.paper51.com

On Error GoTo adderror

http://www.paper51.com

If cmdadd.Caption = "保存"Then 内容来自www.paper51.com

  cmdadd.Caption = "增加"

内容来自www.paper51.com

If Trim(txtnum.Text) = "" Then 内容来自论文无忧网 www.paper51.com

 MsgBox "楼盘编号不能为空!",vbOKOnly + vbExclamation, " " copyright paper51.com

  txtnum.SetFocus

http://www.paper51.com

  Exit Sub

内容来自论文无忧网 www.paper51.com

End If

paper51.com

If Trim(txthuxingnum.Text) = ""Then

内容来自www.paper51.com

  MsgBox "请选择户型编号!",vbOKOnly + vbExclamation, " "

内容来自论文无忧网 www.paper51.com

  Exit Sub

copyright paper51.com

End If 内容来自论文无忧网 www.paper51.com

If Trim(txtprice.Text) = "" Then

内容来自论文无忧网 www.paper51.com

  MsgBox "价格不能为空!",vbOKOnly + vbExclamation, " "

内容来自www.paper51.com

   txtprice.SetFocus paper51.com

  Exit Sub

内容来自www.paper51.com

End If 内容来自论文无忧网 www.paper51.com

If Not IsNumeric(txtprice.Text) Then

http://www.paper51.com

    MsgBox "价格请输入数字!",vbOKOnly + vbExclamation, "" 内容来自www.paper51.com

     txtprice.SetFocus

http://www.paper51.com

     Exit Sub

http://www.paper51.com

End If

内容来自论文无忧网 www.paper51.com

rs_loupan.MoveFirst

内容来自论文无忧网 www.paper51.com

Dim i As Integer 内容来自www.paper51.com

For i = 0 To rs_loupan.RecordCount - 1

内容来自论文无忧网 www.paper51.com

    IfTrim(rs_loupan.Fields(0)) = Trim(txtnum.Text) Then

内容来自论文无忧网 www.paper51.com

    MsgBox "楼盘编号重复!",vbOKOnly + vbExclamation, " "

内容来自www.paper51.com

      txtnum.SetFocus http://www.paper51.com

      Exit Sub paper51.com

   End If 内容来自论文无忧网 www.paper51.com

   rs_loupan.MoveNext

copyright paper51.com

Next i

内容来自www.paper51.com

rs_loupan.MoveLast

copyright paper51.com

rs_loupan.AddNew 内容来自论文无忧网 www.paper51.com

rs_loupan.Fields(0) = Trim(txtnum.Text) http://www.paper51.com

rs_loupan.Fields(1) =Trim(txthuxingnum.Text)

内容来自论文无忧网 www.paper51.com

rs_loupan.Fields(2) =CCur(Trim(txtprice.Text)) 内容来自www.paper51.com

rs_loupan.Update

内容来自论文无忧网 www.paper51.com

MsgBox "添加成功!",vbOKOnly + vbExclamation, "" 内容来自www.paper51.com

cmdadd.Caption = "增加"

paper51.com

With grdLoupan

copyright paper51.com

    .Rows = rs_loupan.RecordCount + 1 内容来自www.paper51.com

    .Row = grdLoupan.Rows - 1 内容来自论文无忧网 www.paper51.com

    .Col = 0

copyright paper51.com

    .Text = Trim(txtnum.Text)

http://www.paper51.com

    .Col = 1 http://www.paper51.com

    .Text = Trim(txthuxingnum.Text) paper51.com

    .Col = 2

paper51.com

    .Text = Trim(txtlouhao.Text) http://www.paper51.com

    .Col = 3

http://www.paper51.com

    .Text = Trim(txtdanyuan.Text)

内容来自www.paper51.com

    .Col = 4

paper51.com

    .Text = Trim(txtlouceng.Text) copyright paper51.com

     .Col= 5 内容来自www.paper51.com

    .Text = Trim(txtfanghao.Text)

http://www.paper51.com

    .Col = 6 http://www.paper51.com

    .Text = Trim(txtprice.Text)

paper51.com

End With 内容来自论文无忧网 www.paper51.com

Else

内容来自论文无忧网 www.paper51.com

  cmdadd.Caption = "保存" paper51.com

  txtnum.Text = "" http://www.paper51.com

  txtprice.Text = "" paper51.com

  cmdmodify.Enabled = False 内容来自论文无忧网 www.paper51.com

  cmddel.Enabled = False

内容来自www.paper51.com

End If http://www.paper51.com

Exit Sub copyright paper51.com

adderror:

内容来自www.paper51.com

  MsgBox Err.Description paper51.com

(2)“修改”按钮的“Click”事件代码 paper51.com

Private Sub cmdmodify_Click() http://www.paper51.com

On Error GoTo modifyerror 内容来自www.paper51.com

txtnum.Enabled = False

copyright paper51.com

If Trim(txtprice.Text) = "" Then 内容来自www.paper51.com

  MsgBox "价格不能为空!",vbOKOnly + vbExclamation, " " http://www.paper51.com

  txtprice.SetFocus 内容来自论文无忧网 www.paper51.com

  Exit Sub 内容来自论文无忧网 www.paper51.com

End If

内容来自论文无忧网 www.paper51.com

If Not IsNumeric(txtprice.Text) Then

paper51.com

   MsgBox "价格请输入数字!",vbOKOnly + vbExclamation, ""

http://www.paper51.com

     txtprice.SetFocus 内容来自www.paper51.com

     Exit Sub

copyright paper51.com

End If 内容来自论文无忧网 www.paper51.com

rs_loupan.MoveFirst paper51.com

Dim i As Integer

内容来自www.paper51.com

For i = 0 To rs_loupan.RecordCount - 1

http://www.paper51.com

    IfTrim(rs_loupan.Fields(0)) = Trim(txtnum.Text) Then copyright paper51.com

      rs_loupan.Fields(0) = Trim(txtnum.Text) 内容来自www.paper51.com

      rs_loupan.Fields(1) = Trim(txthuxingnum.Text) 内容来自www.paper51.com

      rs_loupan.Fields(2) = CCur(Trim(txtprice.Text)) paper51.com

      rs_loupan.Update

http://www.paper51.com

      MsgBox "修改成功!",vbOKOnly + vbExclamation, "" paper51.com

      With grdLoupan 内容来自论文无忧网 www.paper51.com

         .Row = getrow

内容来自论文无忧网 www.paper51.com

         .Col = 1

paper51.com

         .Text = Trim(txthuxingnum.Text)

copyright paper51.com

         .Col = 6

http://www.paper51.com

         .Text = Trim(txtprice.Text)

http://www.paper51.com

      End With 内容来自www.paper51.com

      Exit Sub

paper51.com

   End If

内容来自论文无忧网 www.paper51.com

   rs_loupan.MoveNext paper51.com

Next i 内容来自www.paper51.com

modifyerror:

内容来自www.paper51.com

  MsgBox Err.Description

paper51.com

End Sub 内容来自www.paper51.com

(3)“删除”按钮的“Click”事件代码 内容来自www.paper51.com

Private Sub cmddel_Click() copyright paper51.com

Dim answer As String copyright paper51.com

Dim delete_row As String paper51.com

On Error GoTo delerror

内容来自www.paper51.com

  answer = MsgBox("确定要删除吗?",vbYesNo, "") 内容来自论文无忧网 www.paper51.com

   Ifanswer = vbYes Then

paper51.com

      rs_loupan.MoveFirst 内容来自www.paper51.com

      Dim i As Integer

内容来自论文无忧网 www.paper51.com

      For i = 0 To rs_loupan.RecordCount - 1

内容来自论文无忧网 www.paper51.com

         If Trim(rs_loupan.Fields(0)) = Trim(txtnum.Text) Then

http://www.paper51.com

            rs_loupan.Delete

paper51.com

            rs_loupan.Update 内容来自www.paper51.com

       MsgBox "删除成功!",vbOKOnly + vbExclamation, "" copyright paper51.com

            With grdLoupan 内容来自www.paper51.com

                  .RemoveItem getrow http://www.paper51.com

            End With

copyright paper51.com

            Exit Sub paper51.com

         End If 内容来自www.paper51.com

         rs_loupan.MoveNext copyright paper51.com

      Next i paper51.com

  Else

copyright paper51.com

      Exit Sub paper51.com

  EndIf

copyright paper51.com

Exit Sub 内容来自论文无忧网 www.paper51.com

delerror:

内容来自www.paper51.com

  MsgBox Err.Description

内容来自www.paper51.com

End Sub

http://www.paper51.com

(4)“退出”按钮的“Click”事件代码 内容来自论文无忧网 www.paper51.com

Private Subcmdexit_Click() http://www.paper51.com

Unload Me

内容来自论文无忧网 www.paper51.com

End Sub

paper51.com

------分隔线----------------------------
联系方式