Public c As Integer         '临时存放取得的网格中的坐标
Public r As Integer
Public msf1fouse As Boolean '判断是对MSF1还是对MSF2操作
Public msf2fouse As Boolean
Public Sub showtitle1() '显示MSF1网格是中的标题 MSF1.Clear
  Dim i As Integer
      Dim mrc As ADODB.Recordset
  With MSF1    .Cols = 3
    .TextMatrix(0, 0) = "id"
    .TextMatrix(0, 1) = "加分分数"
    .TextMatrix(0, 2) = "加分内容"
  
    .ColWidth(0) = 1000
    .ColWidth(1) = 1500
    .ColWidth(2) = 2500
  
  
    .FixedRows = 1
  
    For i = 1 To Cols
      .ColAlignment(i) = 0
    Next i
    .FillStyle = flexFillSingle
    .Col = 0
    .Row = 0
    .RowSel = 1
    .ColSel = .Cols - 1
    .CellAlignment = 4
    .Row = 1
    End With
    End Sub
    Public Sub showtitle2() '显示MSF2网格是中的标题 MSF2.Clear
  Dim i As Integer
      Dim mrc As ADODB.Recordset
  With MSF2    .Cols = 3
    .TextMatrix(0, 0) = "id"
  
    .TextMatrix(0, 1) = "减分分数"
    .TextMatrix(0, 2) = "减分内容"
  
    .ColWidth(0) = 1000
    .ColWidth(1) = 1500
    .ColWidth(2) = 2500
    
    .FixedRows = 1
  
    For i = 1 To Cols
      .ColAlignment(i) = 0
    Next i
    .FillStyle = flexFillSingle
    .Col = 0
    .Row = 0
    .RowSel = 1
    .ColSel = .Cols - 1
    .CellAlignment = 4
    .Row = 1
    End With
    End Sub    
  
  
Public Sub showdata1() '显示MSF1网格是内容
On Error GoTo s2
Dim i As Integer
Dim mrc As ADODB.Recordset
Set mrc = New ADODB.Recordset
Set mrc = ExecuteSQL(txtsql1) If mrc.EOF = False Then
   mrc.MoveFirst
  
   
   With MSF1
    .Rows = 2
    .Row = 1
   
    Do While Not mrc.EOF     .Rows = .Rows + 1
     For i = 1 To 2
       .TextMatrix(.Row, i) = mrc.Fields(i + 1)
     Next i
     .TextMatrix(.Row, 0) = mrc.Fields(0)
      .Row = .Row + 1
     mrc.MoveNext
    
       
    Loop
 End With
 
 End If
 
  Set mrc = Nothing
  Exit Sub
s2:
 frmxinxi.MSF1.Refresh
End Sub
Public Sub showdata2() '显示MSF2网格是内容
On Error GoTo s2Dim i As Integer
Dim mrc As ADODB.Recordset
Set mrc = New ADODB.Recordset
Set mrc = ExecuteSQL(txtsql2) If mrc.EOF = False Then
   mrc.MoveFirst
  
   
   With MSF2
    .Rows = 2
    .Row = 1
   
    Do While Not mrc.EOF
     
     .Rows = .Rows + 1
     For i = 1 To 2
       .TextMatrix(.Row, i) = mrc.Fields(i + 1)
     Next i
     .TextMatrix(.Row, 0) = mrc.Fields(0)
      .Row = .Row + 1
     mrc.MoveNext
   
    Loop
 End With
 
 End If
 
  Set mrc = Nothing
  Exit Sub
s2:
 frmxinxi.MSF2.Refresh
End Sub
Private Sub Combo1_DropDown() '找出所有寝室号
Combo1.Clear
Dim mrc As ADODB.Recordset
Set mrc = New ADODB.Recordset
Dim strsql As String
strsql = "select distinct 寝室号 from bedchamber"
Set mrc = ExecuteSQL(strsql)
 If mrc.EOF = False Then
 mrc.MoveFirst
 Do While Not mrc.EOF
 Combo1.AddItem mrc.Fields(0)
 mrc.MoveNext
 Loop
 End IfEnd SubPrivate Sub Combo2_DropDown() '找出相应寝室号中的所有成员
Combo2.Clear
strsql = "select distinct 姓名 from bedchamber where 寝室号=" & Trim(Combo1.Text) & ""
Set mrc = ExecuteSQL(strsql)
 If mrc.EOF = False Then
 mrc.MoveFirst
 Do While Not mrc.EOF
 Combo2.AddItem mrc.Fields(0)
 mrc.MoveNext
 Loop
 End IfEnd SubPrivate Sub Command1_Click()
Dim mrc As ADODB.Recordset
Set mrc = New ADODB.Recordset
If c = 0 Then
 sss = MsgBox("请选择你要修改的项 !", vbExclamation + vbOKOnly, "警告")
      Text3.Visible = False
      Exit Sub
      End If
  If c = 1 Then '加分分数的类型
  
     If Text3.Text = "" Or IsNumeric(Text3.Text) = False Then
      sss = MsgBox("加减分分数要为数值型且不能为空 !", vbExclamation + vbOKOnly, "警告")
      Text3.Visible = False
      Exit Sub
      End If
   End IfIf msf1fouse = True Then
 
   strsql = "select * from addnum where autoid=" & Trim(frmxinxi.MSF1.TextMatrix(r, 0)) & ""
   Set mrc = ExecuteSQL(strsql)
   mrc.Fields(c + 1) = Trim(Text3.Text)
   mrc.Update
   MSF1.TextMatrix(r, c) = Text3.Text
         Text3.Text = ""
         Text3.Visible = False
         msf1fouse = False
   End If
  If msf2fouse = True Then
    
   strsql = "select * from subnum where autoid=" & Trim(frmxinxi.MSF2.TextMatrix(r, 0)) & ""
   Set mrc = ExecuteSQL(strsql)
   mrc.Fields(c + 1) = Trim(Text3.Text)
      mrc.Update
   MSF2.TextMatrix(r, c) = Text3.Text
         Text3.Text = ""
         Text3.Visible = False
         msf2fouse = False
    End If
End SubPrivate Sub Command2_Click() '查找信息
If Text1.Visible = True Then '判断是不是查找窗口Text1.Visible = False
Text2.Visible = False
Combo1.Visible = True
Combo2.Visible = True
Else                    '是查找窗口则进行查找
 strsql = "select id from bedchamber where 寝室号=" & Trim(frmxinxi.Combo1.Text) & " and 姓名='" & Trim(frmxinxi.Combo2.Text) & "'"
     Set mrc = ExecuteSQL(strsql)
     id = mrc.Fields(0)
     txtsql1 = "select * from addnum where addnum.id=" & Trim(id) & "  order by addnum.autoid"
     txtsql2 = "select * from subnum where subnum.id=" & Trim(id) & "  order by subnum.autoid "
   frmxinxi.showtitle1
   frmxinxi.showdata1
   frmxinxi.showtitle2
   frmxinxi.showdata2
End If
End SubPrivate Sub Command3_Click()
Unload Me
frmdefault.ShowEnd SubPrivate Sub Command4_Click()If msf1fouse = True Then
   If MSF1.TextMatrix(MSF1.Row, 0) = "" Then
    sss = MsgBox("请选择要删除的记录 !", vbExclamation + vbOKOnly, "警告")
    Exit Sub
    Else
     If MsgBox("确定要删除该条记录吗?", vbOKCancel + vbExclamation, "警告") = vbOK Then
   strsql = "delete from addnum where autoid=" & Trim(MSF1.TextMatrix(MSF1.Row, 0)) & ""
   ExecuteSQL (strsql)
   Else
   Exit Sub
   End If
   
   End If
Else
 If msf2fouse = True Then
  If MSF2.TextMatrix(MSF2.Row, 0) = "" Then
    sss = MsgBox("请选择要删除的记录 !", vbExclamation + vbOKOnly, "警告")
    Exit Sub
    Else
    If MsgBox("确定要删除该条记录吗?", vbOKCancel + vbExclamation, "警告") = vbOK Then
strsql = "delete from subnum where autoid=" & Trim(MSF2.TextMatrix(MSF2.Row, 0)) & ""
ExecuteSQL (strsql)
Else
   Exit Sub
   End If
End If
End If
End If
If frmxinxi.Text1.Visible = True Then
 strsql = "select id from bedchamber where 寝室号=" & Trim(frmxinxi.Text1.Text) & " and 姓名='" & Trim(frmxinxi.Text2.Text) & "'"
     Set mrc = ExecuteSQL(strsql)
     id = mrc.Fields(0)
     End If
 If frmxinxi.Combo1.Visible = True Then
     strsql = "select id from bedchamber where 寝室号=" & Trim(frmxinxi.Combo1.Text) & " and 姓名='" & Trim(frmxinxi.Combo2.Text) & "'"
     Set mrc = ExecuteSQL(strsql)
     id = mrc.Fields(0)
     End If
     txtsql1 = "select * from addnum where addnum.id=" & Trim(id) & "  order by addnum.autoid"
     txtsql2 = "select * from subnum where subnum.id=" & Trim(id) & "  order by subnum.autoid "
frmxinxi.showtitle1
frmxinxi.showdata1
frmxinxi.showtitle2
frmxinxi.showdata2End SubPrivate Sub Command5_Click()
Dim mrc As ADODB.Recordset
Set mrc = New ADODB.Recordset
If frmxinxi.Text1.Visible = True Then
Label5.Caption = Trim(frmxinxi.Text1.Text) & "寝室的" & Trim(frmxinxi.Text2.Text) & "的情况为:" strsql = "select id from bedchamber where 寝室号=" & Trim(frmxinxi.Text1.Text) & " and 姓名='" & Trim(frmxinxi.Text2.Text) & "'"
     Set mrc = ExecuteSQL(strsql)
     id = mrc.Fields(0)
     End If
 If frmxinxi.Combo1.Visible = True Then
    Label5.Caption = Trim(frmxinxi.Combo1.Text) & "寝室的" & Trim(frmxinxi.Combo2.Text) & "的情况为:"     strsql = "select id from bedchamber where 寝室号=" & Trim(frmxinxi.Combo1.Text) & " and 姓名='" & Trim(frmxinxi.Combo2.Text) & "'"
     Set mrc = ExecuteSQL(strsql)
     id = mrc.Fields(0)
     End If
 strsql = "select sum(加分分数) from addnum where id=" & Trim(id) & ""
     Set mrc = ExecuteSQL(strsql)
    Label3.Caption = "加分分数为:" & mrc.Fields(0) & "分"
     strsql = "select sum(减分分数) from subnum where id=" & Trim(id) & ""
     Set mrc = ExecuteSQL(strsql)
    Label4.Caption = "减分分数为:" & mrc.Fields(0) & "分"  
End SubPrivate Sub Form_Load()
msf1fouse = False
msf2fouse = False
End SubPrivate Sub MSF1_Click()
msf1fouse = True
msf2fouse = False
Text3.Visible = False
End SubPrivate Sub MSF1_DblClick()
msf1fouse = True
msf2fouse = False
With MSF1
 If frmxinxi.MSF1.TextMatrix(.Row, 0) = "" Then
      sss = MsgBox("请选择你要修改的项 !", vbExclamation + vbOKOnly, "警告")
      Text3.Visible = False
      Exit Sub
   End If
r = .Row
c = .Col
Text3.Top = .Top + .RowPos(r) + 15
Text3.Left = .Left + .ColPos(c) + 25
Text3.Width = .ColWidth(c)
Text3.Height = .RowHeight(r) - 15
Text3.Text = .Text
    Text3.SelStart = 0
   Text3.SelLength = Len(Text3.Text)
Text3.Visible = True
Text3.SetFocusEnd WithEnd SubPrivate Sub MSF2_Click()
msf2fouse = True
msf1fouse = False
Text3.Visible = False
End SubPrivate Sub MSF2_DblClick()
msf2fouse = True
msf1fouse = FalseWith MSF2
 If frmxinxi.MSF2.TextMatrix(.Row, 0) = "" Then
      sss = MsgBox("请选择你要修改的项 !", vbExclamation + vbOKOnly, "警告")
       Text3.Visible = False
      Exit Sub
   End If
r = .Row
c = .Col 
Text3.Top = .Top + .RowPos(r) + 15
Text3.Left = .Left + .ColPos(c) + 25
Text3.Width = .ColWidth(c)
Text3.Height = .RowHeight(r) - 15
Text3.Text = .Text
    Text3.SelStart = 0
   Text3.SelLength = Len(Text3.Text)
Text3.Visible = True
Text3.SetFocusEnd WithEnd Sub