Private Sub C修改_Click()
If C修改.Caption = "修改" Then
    If Cell1.DoGetCurrentRow < 2 Then Exit Sub
    
    C插入.Enabled = False
    C修改.Caption = "保存"
    C删除.Enabled = False
    C返回.Caption = "取消"
    CurrentRow = Cell1.DoGetCurrentRow
    Cell1.DoSetCellReadOnly 2, CurrentRow, False
    Cell1.DoSetCellReadOnly 3, CurrentRow, False
    Cell1.DoSetCellReadOnly 4, CurrentRow, False
    Cell1.DoCopyArea 2, CurrentRow, 4, CurrentRow
    Cell2.DoPaste 2, 0, True
    Cell1.DoRedrawRange 0, CurrentRow, 4, CurrentRow
Else
    txtSQL = "update 系部信息表 set 名称= '" & Trim(fGetCellString(2, CurrentRow, Cell1)) _
                          & "', 主任= '" & Trim(fGetCellString(3, CurrentRow, Cell1)) _
                          & "', 书记= '" & Trim(fGetCellString(4, CurrentRow, Cell1)) _
                     & "' where 编号= '" & Trim(fGetCellString(0, CurrentRow, Cell1)) & "'"
    Call ExecuteSQL(txtSQL, msg_Sql)
    If Left(msg_Sql, 4) = "查询错误" Then
        MsgBox "修改数据错误", vbCritical, "错误信息"
        Exit Sub
    End If

    Cell1.DoSetCellReadOnly 1, CurrentRow, True
    Cell1.DoSetCellReadOnly 2, CurrentRow, True
    Cell1.DoSetCellReadOnly 3, CurrentRow, True
    Cell1.DoSetCellReadOnly 4, CurrentRow, True
    Cell1.DoRedrawRange 0, CurrentRow, 4, CurrentRow

    C插入.Enabled = True
    C修改.Caption = "修改"
    C删除.Enabled = True
    C返回.Caption = "返回"
End If

End Sub

