⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmsalemanlogin.frm

📁 一个优秀的售楼系统,可供毕业生毕业设计参考
💻 FRM
📖 第 1 页 / 共 2 页
字号:
If Trim(txtcell.Text) = "" Then
   rs_xiaoshou.Fields(6) = Null
Else
   rs_xiaoshou.Fields(6) = txtcell.Text
End If
rs_xiaoshou.Fields(4) = DTPicker1.Value
If Trim(txtemail.Text) = "" Then
   rs_xiaoshou.Fields(7) = Null
Else
   rs_xiaoshou.Fields(7) = txtemail.Text
End If
If Trim(txtzone.Text) = "" Then
   rs_xiaoshou.Fields(8) = Null
Else
   rs_xiaoshou.Fields(8) = txtzone.Text
End If
If Trim(txtaddr.Text) = "" Then
   rs_xiaoshou.Fields(9) = Null
Else
   rs_xiaoshou.Fields(9) = txtaddr.Text
End If
rs_xiaoshou.Update
MsgBox "添加成功!", vbOKOnly + vbExclamation, "OK"
With MSHFlexGrid1
     .Rows = rs_xiaoshou.RecordCount + 1
     .Row = MSHFlexGrid1.Rows - 1
     .Col = 0
     .Text = txtnum.Text
     .Col = 1
     .Text = txtID.Text
     .Col = 2
     .Text = txtname.Text
     .Col = 3
     .Text = Combo1.Text
     .Col = 4
     .Text = DTPicker1.Value
     .Col = 5
     .Text = txttelnum.Text
     .Col = 6
     .Text = txtcell.Text
     .Col = 7
     .Text = txtemail.Text
     .Col = 8
     .Text = txtzone.Text
     .Col = 9
     .Text = txtaddr.Text
End With
Else
   cmdadd.Caption = "保存"
   txtnum.Text = ""
   txtID.Text = ""
   txtname.Text = ""
   txttelnum.Text = ""
   txtcell.Text = ""
   txtemail.Text = ""
   txtaddr.Text = ""
   txtzone.Text = ""
   cmdmodify.Enabled = False
   cmddel.Enabled = False
End If
Exit Sub
adderror:
   MsgBox Err.Description
End Sub

Private Sub cmdmodify_Click()
On Error GoTo modifyerror
txtnum.Enabled = False
txtID.Enabled = False
If Trim(txtname.Text) = "" Then
   MsgBox "姓名不能为空!", vbOKOnly + vbExclamation, "出错啦!"
   txtname.SetFocus
   Exit Sub
End If
rs_xiaoshou.MoveFirst
Dim i As Integer
For i = 0 To rs_xiaoshou.RecordCount - 1
    If rs_xiaoshou.Fields(0) = txtnum.Text Then
       rs_xiaoshou.Fields(1) = txtID.Text
       rs_xiaoshou.Fields(2) = txtname.Text
       rs_xiaoshou.Fields(3) = Combo1.Text
       If Trim(txttelnum.Text) = "" Then
          rs_xiaoshou.Fields(5) = Null
       Else
          rs_xiaoshou.Fields(5) = txttelnum.Text
       End If
       If Trim(txtcell.Text) = "" Then
          rs_xiaoshou.Fields(6) = Null
       Else
          rs_xiaoshou.Fields(6) = txtcell.Text
       End If
       rs_xiaoshou.Fields(4) = DTPicker1.Value
       If Trim(txtemail.Text) = "" Then
          rs_xiaoshou.Fields(7) = Null
       Else
          rs_xiaoshou.Fields(7) = txtemail.Text
       End If
       If Trim(txtzone.Text) = "" Then
          rs_xiaoshou.Fields(8) = Null
       Else
          rs_xiaoshou.Fields(8) = txtzone.Text
       End If
       If Trim(txtaddr.Text) = "" Then
          rs_xiaoshou.Fields(9) = Null
       Else
          rs_xiaoshou.Fields(9) = txtaddr.Text
       End If
       rs_xiaoshou.Update
       MsgBox "修改成功!", vbOKOnly + vbExclamation, "OK"
       With MSHFlexGrid1
          .Row = getrow
          .Col = 1
          .Text = txtID.Text
          .Col = 2
          .Text = txtname.Text
          .Col = 3
          .Text = Combo1.Text
          .Col = 4
          .Text = DTPicker1.Value
          .Col = 5
          .Text = txttelnum.Text
          .Col = 6
          .Text = txtcell.Text
          .Col = 7
          .Text = txtemail.Text
          .Col = 8
          .Text = txtzone.Text
          .Col = 9
          .Text = txtaddr.Text
       End With
       Exit Sub
    End If
    rs_xiaoshou.MoveNext
Next i
modifyerror:
   MsgBox Err.Description
End Sub

Private Sub cmddel_Click()
Dim answer As String
Dim delete_row As String
On Error GoTo delerror
   answer = MsgBox("确定要删除吗?", vbYesNo, "")
   If answer = vbYes Then
       rs_xiaoshou.MoveFirst
       Dim i As Integer
       For i = 0 To rs_xiaoshou.RecordCount - 1
          If rs_xiaoshou.Fields(0) = txtnum.Text Then
             rs_xiaoshou.Delete
             rs_xiaoshou.Update
             MsgBox "删除成功!", vbOKOnly + vbExclamation, "OK"
             With MSHFlexGrid1
                  .RemoveItem getrow
             End With
             Exit Sub
          End If
          rs_xiaoshou.MoveNext
       Next i
  Else
       Exit Sub
  End If
Exit Sub
delerror:
   MsgBox Err.Description
End Sub

Private Sub cmdexit_Click()
Unload Me
End Sub

Private Sub Form_Load()
Dim sql As String
On Error GoTo loaderror
sql = "select * from 售楼人员"
rs_xiaoshou.CursorLocation = adUseClient
rs_xiaoshou.Open sql, conn, adOpenKeyset, adLockPessimistic
setgrid
setgridhead
displaygrid
Combo1.AddItem "男"
Combo1.AddItem "女"
cmdmodify.Enabled = False
cmddel.Enabled = False
gridclick = False
Exit Sub
loaderror:
   MsgBox Err.Description
End Sub

Public Sub displaygrid()
Dim i As Integer
Dim j As Integer
On Error GoTo displayerror
MSHFlexGrid1.Row = 0
If Not rs_xiaoshou.EOF Then
   rs_xiaoshou.MoveFirst
   Do While Not rs_xiaoshou.EOF
            MSHFlexGrid1.Row = MSHFlexGrid1.Row + 1
            For j = 0 To 9
                MSHFlexGrid1.Col = j
                If Not IsNull(rs_xiaoshou.Fields(j)) Then MSHFlexGrid1.Text = _
                   rs_xiaoshou.Fields(j) Else MSHFlexGrid1.Text = ""
            Next j
            rs_xiaoshou.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 MSHFlexGrid1
    .ScrollBars = flexScrollBarBoth
    .FixedCols = 1
    .Rows = rs_xiaoshou.RecordCount + 1
    .Cols = 10
    .SelectionMode = flexSelectionByRow
For i = 0 To .Rows - 1
    .RowHeight(i) = 315
Next
For i = 0 To .Cols - 1
    .ColWidth(i) = 1500
Next i
End With
Exit Sub
seterror:
     MsgBox Err.Description
End Sub

Public Sub setgridhead()
On Error GoTo setheaderror
MSHFlexGrid1.Row = 0
MSHFlexGrid1.Col = 0
MSHFlexGrid1.Text = "编号"
MSHFlexGrid1.Col = 1
MSHFlexGrid1.Text = "身份证号"
MSHFlexGrid1.Col = 2
MSHFlexGrid1.Text = "姓名"
MSHFlexGrid1.Col = 3
MSHFlexGrid1.Text = "性别"
MSHFlexGrid1.Col = 4
MSHFlexGrid1.Text = "出生日期"
MSHFlexGrid1.Col = 5
MSHFlexGrid1.Text = "电话"
MSHFlexGrid1.Col = 6
MSHFlexGrid1.Text = "手机"
MSHFlexGrid1.Col = 7
MSHFlexGrid1.Text = "电子邮件"
MSHFlexGrid1.Col = 8
MSHFlexGrid1.Text = "邮编"
MSHFlexGrid1.Col = 9
MSHFlexGrid1.Text = "通信地址"
Exit Sub
setheaderror:
   MsgBox Err.Description
End Sub

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

Private Sub MSHFlexGrid1_Click()
On Error GoTo griderror
gridclick = True
cmdmodify.Enabled = True
cmddel.Enabled = True
getrow = MSHFlexGrid1.Row
If MSHFlexGrid1.Rows = 1 Then
   MsgBox "无相关纪录", vbOKOnly + vbExclamation, ""
Else
select_row = MSHFlexGrid1.TextMatrix(getrow, 0)
displaymingxi
End If
griderror:
If Err.Number <> 0 Then
   MsgBox Err.Description
End If
End Sub

Public Sub displaymingxi()
txtnum.Text = select_row
txtID.Text = MSHFlexGrid1.TextMatrix(getrow, 1)
txtname.Text = MSHFlexGrid1.TextMatrix(getrow, 2)
txttelnum.Text = MSHFlexGrid1.TextMatrix(getrow, 5)
txtcell.Text = MSHFlexGrid1.TextMatrix(getrow, 6)
txtemail.Text = MSHFlexGrid1.TextMatrix(getrow, 7)
txtaddr.Text = MSHFlexGrid1.TextMatrix(getrow, 9)
txtzone.Text = MSHFlexGrid1.TextMatrix(getrow, 8)
Combo1.Text = MSHFlexGrid1.TextMatrix(getrow, 3)
DTPicker1.Value = CDate(MSHFlexGrid1.TextMatrix(getrow, 4))
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -