www.pudn.com > textmanager.rar > FrmKeMu.frm, change:2005-04-12,size:10500b


VERSION 5.00 
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX" 
Begin VB.Form FrmKeMu  
   BorderStyle     =   3  'Fixed Dialog 
   ClientHeight    =   5265 
   ClientLeft      =   2565 
   ClientTop       =   1425 
   ClientWidth     =   4260 
   ControlBox      =   0   'False 
   LinkTopic       =   "Form1" 
   LockControls    =   -1  'True 
   MaxButton       =   0   'False 
   MinButton       =   0   'False 
   ScaleHeight     =   5265 
   ScaleWidth      =   4260 
   ShowInTaskbar   =   0   'False 
   StartUpPosition =   2  '屏幕中心 
   Begin VB.CommandButton Command4  
      Caption         =   "修改" 
      BeginProperty Font  
         Name            =   "宋体" 
         Size            =   10.5 
         Charset         =   134 
         Weight          =   400 
         Underline       =   0   'False 
         Italic          =   0   'False 
         Strikethrough   =   0   'False 
      EndProperty 
      Height          =   345 
      Left            =   90 
      TabIndex        =   8 
      Top             =   1095 
      Width           =   900 
   End 
   Begin MSDataGridLib.DataGrid DGKeMu  
      Height          =   3690 
      Left            =   45 
      TabIndex        =   4 
      Top             =   1515 
      Width           =   4170 
      _ExtentX        =   7355 
      _ExtentY        =   6509 
      _Version        =   393216 
      AllowUpdate     =   0   'False 
      BackColor       =   15267064 
      HeadLines       =   1 
      RowHeight       =   18 
      BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}  
         Name            =   "宋体" 
         Size            =   14.25 
         Charset         =   134 
         Weight          =   400 
         Underline       =   0   'False 
         Italic          =   0   'False 
         Strikethrough   =   0   'False 
      EndProperty 
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}  
         Name            =   "宋体" 
         Size            =   12 
         Charset         =   134 
         Weight          =   400 
         Underline       =   0   'False 
         Italic          =   0   'False 
         Strikethrough   =   0   'False 
      EndProperty 
      ColumnCount     =   2 
      BeginProperty Column00  
         DataField       =   "" 
         Caption         =   "" 
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}  
            Type            =   0 
            Format          =   "" 
            HaveTrueFalseNull=   0 
            FirstDayOfWeek  =   0 
            FirstWeekOfYear =   0 
            LCID            =   2052 
            SubFormatType   =   0 
         EndProperty 
      EndProperty 
      BeginProperty Column01  
         DataField       =   "" 
         Caption         =   "" 
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}  
            Type            =   0 
            Format          =   "" 
            HaveTrueFalseNull=   0 
            FirstDayOfWeek  =   0 
            FirstWeekOfYear =   0 
            LCID            =   2052 
            SubFormatType   =   0 
         EndProperty 
      EndProperty 
      SplitCount      =   1 
      BeginProperty Split0  
         MarqueeStyle    =   3 
         BeginProperty Column00  
         EndProperty 
         BeginProperty Column01  
         EndProperty 
      EndProperty 
   End 
   Begin VB.Frame Frame1  
      Height          =   840 
      Left            =   30 
      TabIndex        =   5 
      Top             =   195 
      Width           =   4170 
      Begin VB.TextBox TxTName  
         Appearance      =   0  'Flat 
         BackColor       =   &H00E8F4F8& 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   14.25 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         ForeColor       =   &H00000080& 
         Height          =   360 
         Left            =   270 
         TabIndex        =   6 
         Top             =   420 
         Width           =   3720 
      End 
      Begin VB.Label Label2  
         AutoSize        =   -1  'True 
         Caption         =   "科目名称:" 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   12 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         ForeColor       =   &H00FF0000& 
         Height          =   240 
         Left            =   225 
         TabIndex        =   7 
         Top             =   150 
         Width           =   1200 
      End 
   End 
   Begin VB.CommandButton Command3  
      BackColor       =   &H00808080& 
      Caption         =   "X" 
      Height          =   195 
      Left            =   4080 
      Style           =   1  'Graphical 
      TabIndex        =   2 
      Top             =   -15 
      Width           =   180 
   End 
   Begin VB.CommandButton Command2  
      Caption         =   "删除" 
      BeginProperty Font  
         Name            =   "宋体" 
         Size            =   10.5 
         Charset         =   134 
         Weight          =   400 
         Underline       =   0   'False 
         Italic          =   0   'False 
         Strikethrough   =   0   'False 
      EndProperty 
      Height          =   345 
      Left            =   3195 
      TabIndex        =   1 
      Top             =   1110 
      Width           =   900 
   End 
   Begin VB.CommandButton Command1  
      Caption         =   "添加" 
      BeginProperty Font  
         Name            =   "宋体" 
         Size            =   10.5 
         Charset         =   134 
         Weight          =   400 
         Underline       =   0   'False 
         Italic          =   0   'False 
         Strikethrough   =   0   'False 
      EndProperty 
      Height          =   345 
      Left            =   2235 
      TabIndex        =   0 
      Top             =   1110 
      Width           =   900 
   End 
   Begin VB.Label Label1  
      BackColor       =   &H8000000B& 
      BackStyle       =   0  'Transparent 
      Height          =   135 
      Left            =   0 
      TabIndex        =   3 
      Top             =   15 
      Width           =   4095 
   End 
   Begin VB.Line Line1  
      BorderColor     =   &H00808080& 
      X1              =   15 
      X2              =   4170 
      Y1              =   120 
      Y2              =   120 
   End 
   Begin VB.Line Line2  
      BorderColor     =   &H00E0E0E0& 
      X1              =   30 
      X2              =   4185 
      Y1              =   135 
      Y2              =   135 
   End 
   Begin VB.Line Line3  
      BorderColor     =   &H00808080& 
      X1              =   30 
      X2              =   4140 
      Y1              =   45 
      Y2              =   45 
   End 
   Begin VB.Line Line4  
      BorderColor     =   &H00E0E0E0& 
      X1              =   45 
      X2              =   4155 
      Y1              =   60 
      Y2              =   60 
   End 
End 
Attribute VB_Name = "FrmKeMu" 
Attribute VB_GlobalNameSpace = False 
Attribute VB_Creatable = False 
Attribute VB_PredeclaredId = True 
Attribute VB_Exposed = False 
Option Explicit 
 
Private Sub Command1_Click() 
 If TXTName.Text = "" Then 
    MsgBox "请输入科目名称!", 48, "提示!" 
    TXTName.SetFocus 
    Exit Sub 
 End If 
 Dim TempRs As Recordset 
 Set TempRs = New Recordset 
 TempRs.Open "select * from kemu where name='" + TXTName + "'", DB, adOpenStatic, adLockOptimistic 
 If TempRs.RecordCount > 0 Then 
    MsgBox "这个科目已经存在,请重新定义!", 48, "提示" 
    TXTName.SetFocus 
    SendKeys "{Home}+{end}" 
    Exit Sub 
 End If 
 TempRs.Close 
 '写入数据库 
 Dim sql As String 
 sql = "insert into kemu values(" + Int2Str(GetAutoID("kemu")) + ",'" + TXTName + "')" 
 DB.Execute sql 
 '刷新 
 Form_Load 
End Sub 
 
Private Sub Command2_Click() 
 Dim sql As String 
 If DGKeMu.Row < 0 Then Exit Sub 
 If DGKeMu.Columns(0).Text <> "" Then 
    '判断是否有这个科目的题目 
    Dim TempRs As Recordset 
    Set TempRs = New Recordset 
    TempRs.Open "select id from question where kemuid=" + DGKeMu.Columns(0).Text, DB, adOpenStatic, adLockOptimistic 
    If TempRs.RecordCount > 0 Then 
       MsgBox "因为题目库里还有含有这个科目的题目,所以不能删除!" 
       Exit Sub 
    End If 
    If MsgBox("你真的要删除科目< " + DGKeMu.Text + " >吗?", vbYesNo, "问题?") = vbYes Then 
       sql = "delete from kemu where id=" + DGKeMu.Columns(0).Text 
       DB.Execute sql 
    End If 
 End If 
 '更新 
 Form_Load 
End Sub 
 
Private Sub Command3_Click() 
 Unload Me 
End Sub 
 
Private Sub Command4_Click() 
 If DGKeMu.ApproxCount = 0 Then 
   MsgBox "现在还没有科目!" 
   Exit Sub 
 End If 
  
 If TXTName.Text = "" Then 
    MsgBox "请输入科目名称!", 48, "提示!" 
    TXTName.SetFocus 
    Exit Sub 
 End If 
 Dim TempRs As Recordset 
 Set TempRs = New Recordset 
 TempRs.Open "select * from kemu where name='" + TXTName + "'", DB, adOpenStatic, adLockOptimistic 
 If TempRs.RecordCount > 0 Then 
    MsgBox "这个科目已经存在,请重新定义!", 48, "提示" 
    TXTName.SetFocus 
    SendKeys "{Home}+{end}" 
    Exit Sub 
 End If 
 TempRs.Close 
 '修改数据库 
 Dim sql As String 
 sql = "update kemu set name='" + TXTName.Text + "' where id=" + DGKeMu.Columns(0).Text 
 DB.Execute sql 
 '刷新 
 Form_Load 
End Sub 
 
Private Sub DGKeMu_Click() 
   If DGKeMu.ApproxCount <= 0 Then Exit Sub 
   TXTName.Text = DGKeMu.Columns(1).Text 
End Sub 
 
Private Sub Form_Activate() 
 TXTName.SetFocus 
End Sub 
 
 
Private Sub Form_Load() 
  Dim adokemuRs As Recordset 
  '打开记录集 
  Set adokemuRs = New Recordset 
  adokemuRs.Open "select id as 科目ID,name as 科目名称 from kemu", DB, adOpenStatic, adLockOptimistic 
  Set DGKeMu.DataSource = adokemuRs 
   
End Sub 
 
Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) 
      ReleaseCapture 
 Dim ret As Long 
  ret = SendMessage(Me.hwnd, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0) 
 
End Sub 
 
Private Sub TXTName_KeyPress(KeyAscii As Integer) 
    If KeyAscii = 39 Then KeyAscii = -24145 
 
End Sub