论文无忧网提供:计算机毕业论文范文|计算机毕业设计|计算机毕业论文
栏目导航 ASP JSP .NET VB6.0 JAVA VC VF DELPHI PB 计算机网络 计算机科学与技术 PHP 其他 代写论文

A400201AC售楼管理系统

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

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

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

http://www.snowings.com

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

Private Sub cmdadd_Click() 内容来自www.snowings.com

    OnError GoTo adderror

copyright paper51.com

    IfcmdAdd.Caption = "保  存"Then

paper51.com

       '下面对输入的有效性进行验证

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

       If Trim(txtHuxingnum.Text) = "" Then

copyright paper51.com

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

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

          txtHuxingnum.SetFocus paper51.com

          Exit Sub

http://www.snowings.com

       End If

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

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

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

          Combo1.SetFocus 内容来自www.snowings.com

          Exit Sub copyright paper51.com

       End If

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

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

 MsgBox "建筑面积不能为空!",vbOKOnly + vbExclamation, " "

内容来自www.snowings.com

          txtJianzhumianji.SetFocus

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

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

       End If

内容来自www.snowings.com

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

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

          txtTaomianji.SetFocus

http://www.snowings.com

          Exit Sub

内容来自www.snowings.com

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

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

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

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

http://www.snowings.com

             txtJianzhumianji.SetFocus

http://www.snowings.com

             Exit Sub

http://www.snowings.com

       End If paper51.com

       If Not IsNumeric(txtTaomianji.Text) Then

paper51.com

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

http://www.snowings.com

             txtTaomianji.SetFocus 内容来自www.snowings.com

             Exit Sub

copyright paper51.com

       End If

copyright paper51.com

      

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

如果当前按钮的状态为“保存”状态,则需要将新添加的数据写进数据库。

内容来自www.snowings.com

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

内容来自www.snowings.com

On Error GoTo adderror

http://www.snowings.com

    IfcmdAdd.Caption = "保  存"Then 内容来自论文无忧网 www.snowings.com

       '下面对输入的有效性进行验证 内容来自www.snowings.com

       If Trim(txtHuxingnum.Text) = "" Then

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

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

          txtHuxingnum.SetFocus 内容来自论文无忧网 www.snowings.com

          Exit Sub

http://www.snowings.com

       End If copyright paper51.com

       If Trim(txtFangxing.Text) = "" Then

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

      MsgBox "请选择房型!",vbOKOnly + vbExclamation, " " http://www.snowings.com

          Combo1.SetFocus

内容来自www.snowings.com

          Exit Sub

copyright paper51.com

       End If

内容来自www.snowings.com

       If Trim(txtJianzhumianji.Text) = "" Then

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

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

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

          Exit Sub paper51.com

       End If copyright paper51.com

       If Trim(txtTaomianji.Text) = "" Then

paper51.com

          MsgBox "套内面积不能为空!",vbOKOnly + vbExclamation, " "

内容来自www.snowings.com

          txtTaomianji.SetFocus copyright paper51.com

          Exit Sub paper51.com

       End If

内容来自www.snowings.com

       If Not IsNumeric(txtJianzhumianji.Text) Then  '面积必须是数值

内容来自www.snowings.com

             MsgBox "建筑面积请输入数字!",vbOKOnly + vbExclamation, "" http://www.snowings.com

             txtJianzhumianji.SetFocus copyright paper51.com

              Exit Sub

copyright paper51.com

       End If

http://www.snowings.com

       If Not IsNumeric(txtTaomianji.Text) Then http://www.snowings.com

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

             txtTaomianji.SetFocus

http://www.snowings.com

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

       End If

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

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

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

       Dim i As Integer http://www.snowings.com

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

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

 IfTrim(rs_huxing.Fields(0)) = Trim(txtHuxingnum.Text) Then 内容来自www.snowings.com

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

内容来自www.snowings.com

               txtHuxingnum.SetFocus

copyright paper51.com

               Exit Sub 内容来自www.snowings.com

           End If http://www.snowings.com

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

       Next i

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

如果没有重复,则将新的数据添加到数据库中。注意,数据库中的字段格式应该和即将添加的数据格式一致。添加完毕后使用Update方法更新数据库。 内容来自论文无忧网 www.snowings.com

  rs_huxing.MoveLast     '户型编号不存在,在最后插入新纪录

内容来自www.snowings.com

       rs_huxing.AddNew

paper51.com

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

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

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

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

       rs_huxing.Fields(3) = Trim(txtFangxing.Text) 内容来自www.snowings.com

       rs_huxing.Fields(4) = Trim(txtJianjie.Text) http://www.snowings.com

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

       rs_huxing.Update                                '将插入的记录保存

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

       MsgBox "添加成功!",vbOKOnly + vbExclamation, "" paper51.com

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

With grdHuxing             '将表格最后一行数据更新

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

            .Rows = rs_huxing.RecordCount + 1

copyright paper51.com

            .Row = grdHuxing.Rows - 1 paper51.com

            .Col = 0 copyright paper51.com

            .Text = Trim(txtHuxingnum.Text) 内容来自www.snowings.com

            .Col = 1

copyright paper51.com

            .Text = Trim(txtJianzhumianji.Text) http://www.snowings.com

            .Col = 2

http://www.snowings.com

            .Text = Trim(txtTaomianji.Text) 内容来自论文无忧网 www.snowings.com

            .Col = 3

paper51.com

            .Text = Trim(txtFangxing.Text)

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

            .Col = 4

内容来自www.snowings.com

            .Text = Trim(txtFangxing.Text) 内容来自论文无忧网 www.snowings.com

            .Col = 5 copyright paper51.com

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

       End With http://www.snowings.com

 cmdAdd.Caption = "增  加"  '成功保存后标题变为“增  加” http://www.snowings.com

   Else                    '按钮标题为"增  加"时

copyright paper51.com

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

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

       txtJianzhumianji.Text = "" 内容来自论文无忧网 www.snowings.com

       txtTaomianji.Text = "" paper51.com

       txtJianjie.Text = ""

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

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

http://www.snowings.com

       cmdDel.Enabled = False 内容来自www.snowings.com

 cmdAdd.Caption = "保  存"          '按钮标题变为“保  存” 内容来自www.snowings.com

   End If

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

   Exit Sub

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

adderror: 内容来自论文无忧网 www.snowings.com

      MsgBox Err.Description

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

End Sub

http://www.snowings.com

4.3.2建立楼盘登记窗体(frmBuildingLogin) 内容来自www.snowings.com

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

http://www.snowings.com

1、界面设计

paper51.com

与设计户型登记窗体相似,在工程中添加一个窗体,命名为frmBuildingLogin。设置好控件及属性的frmBuildingLogin窗体如图6所示。 copyright paper51.com

paper51.com

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

copyright paper51.com

2、工程流程

paper51.com

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

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

copyright paper51.com

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

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

3、添加代码 内容来自www.snowings.com

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

paper51.com

Private Sub cmdadd_Click()

http://www.snowings.com

On Error GoTo adderror 内容来自www.snowings.com

If cmdadd.Caption = "保存"Then 内容来自论文无忧网 www.snowings.com

  cmdadd.Caption = "增加"

内容来自www.snowings.com

If Trim(txtnum.Text) = "" Then 内容来自www.snowings.com

 MsgBox "楼盘编号不能为空!",vbOKOnly + vbExclamation, " "

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

  txtnum.SetFocus paper51.com

  Exit Sub

copyright paper51.com

End If

paper51.com

If Trim(txthuxingnum.Text) = ""Then

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

  MsgBox "请选择户型编号!",vbOKOnly + vbExclamation, " " copyright paper51.com

  Exit Sub

内容来自www.snowings.com

End If

copyright paper51.com

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

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

copyright paper51.com

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

  Exit Sub

内容来自www.snowings.com

End If

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

If Not IsNumeric(txtprice.Text) Then

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

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

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

     txtprice.SetFocus

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

     Exit Sub

http://www.snowings.com

End If

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

rs_loupan.MoveFirst paper51.com

Dim i As Integer

http://www.snowings.com

For i = 0 To rs_loupan.RecordCount - 1 http://www.snowings.com

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

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

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

      txtnum.SetFocus paper51.com

      Exit Sub

paper51.com

   End If copyright paper51.com

   rs_loupan.MoveNext http://www.snowings.com

Next i 内容来自www.snowings.com

rs_loupan.MoveLast http://www.snowings.com

rs_loupan.AddNew copyright paper51.com

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

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

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

paper51.com

rs_loupan.Update

copyright paper51.com

MsgBox "添加成功!",vbOKOnly + vbExclamation, ""

paper51.com

cmdadd.Caption = "增加" http://www.snowings.com

With grdLoupan

内容来自www.snowings.com

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

    .Row = grdLoupan.Rows - 1 http://www.snowings.com

    .Col = 0 paper51.com

    .Text = Trim(txtnum.Text)

copyright paper51.com

    .Col = 1

http://www.snowings.com

    .Text = Trim(txthuxingnum.Text)

copyright paper51.com

    .Col = 2 http://www.snowings.com

    .Text = Trim(txtlouhao.Text)

http://www.snowings.com

    .Col = 3

copyright paper51.com

    .Text = Trim(txtdanyuan.Text)

内容来自www.snowings.com

    .Col = 4 copyright paper51.com

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

     .Col= 5

copyright paper51.com

    .Text = Trim(txtfanghao.Text) 内容来自论文无忧网 www.snowings.com

    .Col = 6

内容来自www.snowings.com

    .Text = Trim(txtprice.Text)

paper51.com

End With paper51.com

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

  cmdadd.Caption = "保存"

http://www.snowings.com

  txtnum.Text = ""

http://www.snowings.com

  txtprice.Text = ""

内容来自www.snowings.com

  cmdmodify.Enabled = False

http://www.snowings.com

  cmddel.Enabled = False

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

End If paper51.com

Exit Sub

内容来自www.snowings.com

adderror:

copyright paper51.com

  MsgBox Err.Description http://www.snowings.com

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

Private Sub cmdmodify_Click()

http://www.snowings.com

On Error GoTo modifyerror paper51.com

txtnum.Enabled = False

内容来自www.snowings.com

If Trim(txtprice.Text) = "" Then

copyright paper51.com

  MsgBox "价格不能为空!",vbOKOnly + vbExclamation, " " 内容来自www.snowings.com

  txtprice.SetFocus http://www.snowings.com

  Exit Sub http://www.snowings.com

End If

内容来自www.snowings.com

If Not IsNumeric(txtprice.Text) Then 内容来自论文无忧网 www.snowings.com

   MsgBox "价格请输入数字!",vbOKOnly + vbExclamation, "" copyright paper51.com

     txtprice.SetFocus http://www.snowings.com

     Exit Sub

内容来自www.snowings.com

End If

copyright paper51.com

rs_loupan.MoveFirst

paper51.com

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

For i = 0 To rs_loupan.RecordCount - 1 http://www.snowings.com

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

内容来自www.snowings.com

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

paper51.com

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

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

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

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

      rs_loupan.Update

http://www.snowings.com

      MsgBox "修改成功!",vbOKOnly + vbExclamation, ""

paper51.com

      With grdLoupan copyright paper51.com

         .Row = getrow

copyright paper51.com

         .Col = 1

http://www.snowings.com

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

         .Col = 6 copyright paper51.com

         .Text = Trim(txtprice.Text)

paper51.com

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

      Exit Sub

paper51.com

   End If

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

   rs_loupan.MoveNext 内容来自论文无忧网 www.snowings.com

Next i

copyright paper51.com

modifyerror: 内容来自论文无忧网 www.snowings.com

  MsgBox Err.Description 内容来自论文无忧网 www.snowings.com

End Sub

paper51.com

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

Private Sub cmddel_Click()

内容来自www.snowings.com

Dim answer As String 内容来自www.snowings.com

Dim delete_row As String copyright paper51.com

On Error GoTo delerror

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

  answer = MsgBox("确定要删除吗?",vbYesNo, "")

http://www.snowings.com

   Ifanswer = vbYes Then copyright paper51.com

      rs_loupan.MoveFirst 内容来自论文无忧网 www.snowings.com

      Dim i As Integer http://www.snowings.com

      For i = 0 To rs_loupan.RecordCount - 1

http://www.snowings.com

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

http://www.snowings.com

            rs_loupan.Delete

http://www.snowings.com

            rs_loupan.Update 内容来自论文无忧网 www.snowings.com

       MsgBox "删除成功!",vbOKOnly + vbExclamation, "" 内容来自www.snowings.com

            With grdLoupan

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

                  .RemoveItem getrow

paper51.com

            End With copyright paper51.com

            Exit Sub

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

         End If

copyright paper51.com

         rs_loupan.MoveNext

http://www.snowings.com

      Next i 内容来自论文无忧网 www.snowings.com

  Else

内容来自www.snowings.com

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

  EndIf paper51.com

Exit Sub paper51.com

delerror:

内容来自www.snowings.com

  MsgBox Err.Description paper51.com

End Sub

copyright paper51.com

(4)“退出”按钮的“Click”事件代码

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

Private Subcmdexit_Click()

paper51.com

Unload Me 内容来自论文无忧网 www.snowings.com

End Sub 内容来自论文无忧网 www.snowings.com

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