以下是引用片段:
其主要代码实现如下: Private Sub Form_Load() If frmMain.Tag = "" Then '初始化控件 Me.Toolbar1.Buttons(2).Enabled = False Me.Combo5.ListIndex = 0 Me.DTPicker1.Value = Date Else '根据当前的编号 显示看房记录信息 Dim tmprs As New ADODB.Recordset Set tmprs = GetSql("SELECT * FROM 看房记录 where 看房编号=" & frmMain.Tag) With tmprs If .RecordCount > 0 Then Me.Text1(5).Tag = .Fields("房屋登记编号").Value Me.Text1(1).Tag = .Fields("客户编号").Value Me.DTPicker1.Value = .Fields("看房时间").Value Me.Combo5.ListIndex = GetIndex(Me.Combo5, .Fields("看房结果").Value) Me.Text1(10).Text = .Fields("备注").Value Dim i As Long Dim tmprs1 As New ADODB.Recordset Set tmprs1 = GetSql("SELECT 房屋登记.房屋登记编号, 房屋登记.登记日期, 房屋登记.联系人, 房屋登记.房屋类型, 区域.区域名称, 房屋登记.具体地址, 房型.房型名称, 房屋登记.是否产权, 房屋登记.楼层, 房屋登记.建筑时间, 房屋登记.建筑面积, 房屋登记.房屋总价, 房屋登记.装修情况, 房屋登记.实用面积, 房屋登记.业主名称, 房屋登记.联系电话, 房屋登记.备注, 房屋登记.是否售出 FROM (房屋登记 INNER JOIN 房型 ON 房屋登记.房型编号 = 房型.房型编号) INNER JOIN 区域 ON 房屋登记.区域编号 = 区域.区域编号 where 房屋登记.房屋登记编号 =" & Me.Text1(5).Tag) If tmprs1.RecordCount > 0 Then Me.Text1(5).Text = "" For i = 1 To tmprs1.Fields.Count - 2 Me.Text1(5).Text = Me.Text1(5).Text & tmprs1.Fields.Item(i).Name & ":" & Trim(tmprs1.Fields(i).Value) & vbCrLf Next End If Set tmprs1 = GetSql("SELECT 客户登记.客户登记编号, 客户登记.登记日期, 客户登记.接待人员, 客户登记.客户名称, 客户登记.联系手机, 客户登记.固定电话, 区域.区域名称, 客户登记.意向楼层, 房型.房型名称, 客户登记.最小建筑面积, 客户登记.意向总价, 客户登记.付款方式, 客户登记.装修情况 FROM (客户登记 INNER JOIN 区域 ON 客户登记.区域编号 = 区域.区域编号) INNER JOIN 房型 ON 客户登记.房型编号 = 房型.房型编号 where 客户登记.客户登记编号 =" & Me.Text1(1).Tag) If tmprs1.RecordCount > 0 Then Me.Text1(1).Text = "" For i = 1 To tmprs1.Fields.Count - 1 Me.Text1(1).Text = Me.Text1(1).Text & tmprs1.Fields.Item(i).Name & ":" & Trim(tmprs1.Fields(i).Value) & vbCrLf Next End If End If End With End If End Sub
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Index Case 1 If Me.Text1(1).Text = "" Or Me.Text1(5).Text = "" Then MsgBox "房屋信息或客户信息不能为空" Exit Sub End If '根据标志 添加或修改看房记录信息 If frmMain.Tag = "" Then Call SetSql("insert into 看房记录(房屋登记编号,客户编号,看房时间,看房结果,备注) " _ & " values(" & Me.Text1(5).Tag & "," & Me.Text1(1).Tag & ", " _ & " '" & Me.DTPicker1.Value & "','" & Me.Combo5.Text & "','" & Me.Text1(10).Text & "')") Else Call SetSql("update 看房记录 set 房屋登记编号=" & Me.Text1(5).Tag & ", " _ & " 客户编号=" & Me.Text1(1).Tag & ",看房时间='" & Me.DTPicker1.Value & "'," _ & " 看房结果='" & Me.Combo5.Text & "',备注='" & Me.Text1(10).Text & "' where 看房编号=" & frmMain.Tag) End If Case 2 '删除看房记录信息 Call SetSql("delete from 看房记录 where 看房编号=" & frmMain.Tag) Case 3 End Select Unload Me
|