www.pudn.com > textmanager.rar > FRMNianJi.FRM, change:2005-04-12,size:18595b


VERSION 5.00 
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX" 
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX" 
Begin VB.Form FrmNianJi  
   BorderStyle     =   3  'Fixed Dialog 
   ClientHeight    =   5565 
   ClientLeft      =   2760 
   ClientTop       =   3465 
   ClientWidth     =   5655 
   ControlBox      =   0   'False 
   KeyPreview      =   -1  'True 
   LinkTopic       =   "Form1" 
   LockControls    =   -1  'True 
   MaxButton       =   0   'False 
   MinButton       =   0   'False 
   ScaleHeight     =   5565 
   ScaleWidth      =   5655 
   ShowInTaskbar   =   0   'False 
   StartUpPosition =   2  '屏幕中心 
   Begin VB.Frame Frame1  
      Caption         =   "年级信息维护" 
      BeginProperty Font  
         Name            =   "宋体" 
         Size            =   10.5 
         Charset         =   134 
         Weight          =   400 
         Underline       =   0   'False 
         Italic          =   0   'False 
         Strikethrough   =   0   'False 
      EndProperty 
      Height          =   5295 
      Left            =   45 
      TabIndex        =   1 
      Top             =   225 
      Width           =   5580 
      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            =   135 
         TabIndex        =   15 
         Top             =   1365 
         Width           =   900 
      End 
      Begin VB.CommandButton Command3  
         Caption         =   "添加" 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   10.5 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         Height          =   345 
         Left            =   3345 
         TabIndex        =   8 
         Top             =   1365 
         Width           =   900 
      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            =   4365 
         TabIndex        =   7 
         Top             =   1365 
         Width           =   900 
      End 
      Begin VB.Frame Frame2  
         Height          =   1035 
         Left            =   75 
         TabIndex        =   3 
         Top             =   210 
         Width           =   5430 
         Begin VB.TextBox TxTCount  
            Appearance      =   0  'Flat 
            BackColor       =   &H00E8F4F8& 
            Enabled         =   0   'False 
            BeginProperty Font  
               Name            =   "宋体" 
               Size            =   10.5 
               Charset         =   134 
               Weight          =   400 
               Underline       =   0   'False 
               Italic          =   0   'False 
               Strikethrough   =   0   'False 
            EndProperty 
            Height          =   315 
            Left            =   4020 
            Locked          =   -1  'True 
            TabIndex        =   11 
            Text            =   "1" 
            Top             =   600 
            Width           =   465 
         End 
         Begin VB.TextBox TxTNum  
            Appearance      =   0  'Flat 
            BackColor       =   &H00E8F4F8& 
            BeginProperty Font  
               Name            =   "宋体" 
               Size            =   10.5 
               Charset         =   134 
               Weight          =   400 
               Underline       =   0   'False 
               Italic          =   0   'False 
               Strikethrough   =   0   'False 
            EndProperty 
            Height          =   315 
            Left            =   1110 
            Locked          =   -1  'True 
            TabIndex        =   9 
            Text            =   "1" 
            ToolTipText     =   "年级序号是指该年级名称代表的实际年级,比如:一年级是1,二年级是2" 
            Top             =   600 
            Width           =   330 
         End 
         Begin VB.TextBox TXTname  
            Appearance      =   0  'Flat 
            BackColor       =   &H00E8F4F8& 
            BeginProperty Font  
               Name            =   "宋体" 
               Size            =   10.5 
               Charset         =   134 
               Weight          =   400 
               Underline       =   0   'False 
               Italic          =   0   'False 
               Strikethrough   =   0   'False 
            EndProperty 
            Height          =   315 
            Left            =   1110 
            TabIndex        =   5 
            Top             =   180 
            Width           =   3855 
         End 
         Begin MSComCtl2.UpDown UpDown1  
            Height          =   315 
            Left            =   4471 
            TabIndex        =   10 
            Top             =   600 
            Width           =   270 
            _ExtentX        =   476 
            _ExtentY        =   556 
            _Version        =   393216 
            Value           =   1 
            BuddyControl    =   "TxTCount" 
            BuddyDispid     =   196614 
            OrigLeft        =   4905 
            OrigTop         =   600 
            OrigRight       =   5175 
            OrigBottom      =   915 
            Max             =   20 
            Min             =   1 
            SyncBuddy       =   -1  'True 
            BuddyProperty   =   0 
            Enabled         =   -1  'True 
         End 
         Begin MSComCtl2.UpDown UpDown2  
            Height          =   315 
            Left            =   1425 
            TabIndex        =   12 
            ToolTipText     =   "年级序号是指该年级名称代表的实际年级,比如:一年级是1,二年级是2" 
            Top             =   600 
            Width           =   270 
            _ExtentX        =   476 
            _ExtentY        =   556 
            _Version        =   393216 
            Value           =   1 
            BuddyControl    =   "TxTNum" 
            BuddyDispid     =   196615 
            OrigLeft        =   1515 
            OrigTop         =   585 
            OrigRight       =   1785 
            OrigBottom      =   900 
            Max             =   20 
            Min             =   1 
            SyncBuddy       =   -1  'True 
            BuddyProperty   =   0 
            Enabled         =   -1  'True 
         End 
         Begin VB.Label Label3  
            Caption         =   "该年级班数:" 
            BeginProperty Font  
               Name            =   "宋体" 
               Size            =   10.5 
               Charset         =   134 
               Weight          =   400 
               Underline       =   0   'False 
               Italic          =   0   'False 
               Strikethrough   =   0   'False 
            EndProperty 
            Height          =   270 
            Left            =   2835 
            TabIndex        =   14 
            Top             =   645 
            Width           =   1200 
         End 
         Begin VB.Label Label5  
            Caption         =   "年级序号:" 
            BeginProperty Font  
               Name            =   "宋体" 
               Size            =   10.5 
               Charset         =   134 
               Weight          =   400 
               Underline       =   0   'False 
               Italic          =   0   'False 
               Strikethrough   =   0   'False 
            EndProperty 
            Height          =   270 
            Left            =   150 
            TabIndex        =   13 
            ToolTipText     =   "年级序号是指该年级名称代表的实际年级,比如:一年级是1,二年级是2" 
            Top             =   660 
            Width           =   975 
         End 
         Begin VB.Label Label1  
            Caption         =   "年级名称:" 
            BeginProperty Font  
               Name            =   "宋体" 
               Size            =   10.5 
               Charset         =   134 
               Weight          =   400 
               Underline       =   0   'False 
               Italic          =   0   'False 
               Strikethrough   =   0   'False 
            EndProperty 
            Height          =   270 
            Left            =   165 
            TabIndex        =   4 
            Top             =   240 
            Width           =   975 
         End 
      End 
      Begin MSDataGridLib.DataGrid DGNianJi  
         Height          =   3375 
         Left            =   75 
         TabIndex        =   2 
         Top             =   1845 
         Width           =   5445 
         _ExtentX        =   9604 
         _ExtentY        =   5953 
         _Version        =   393216 
         AllowUpdate     =   0   'False 
         BackColor       =   15267064 
         ForeColor       =   -2147483635 
         HeadLines       =   1 
         RowHeight       =   18 
         BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}  
            Name            =   "宋体" 
            Size            =   12 
            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 
   End 
   Begin VB.CommandButton Command1  
      BackColor       =   &H00808080& 
      Caption         =   "X" 
      Height          =   195 
      Left            =   5400 
      Style           =   1  'Graphical 
      TabIndex        =   0 
      Top             =   -15 
      Width           =   180 
   End 
   Begin VB.Label Label4  
      BackStyle       =   0  'Transparent 
      Height          =   195 
      Left            =   15 
      TabIndex        =   6 
      Top             =   -15 
      Width           =   5685 
   End 
   Begin VB.Line Line4  
      BorderColor     =   &H00E0E0E0& 
      BorderWidth     =   2 
      X1              =   0 
      X2              =   5640 
      Y1              =   135 
      Y2              =   135 
   End 
   Begin VB.Line Line3  
      BorderColor     =   &H00808080& 
      BorderWidth     =   2 
      X1              =   0 
      X2              =   5955 
      Y1              =   120 
      Y2              =   105 
   End 
   Begin VB.Line Line2  
      BorderColor     =   &H00E0E0E0& 
      BorderWidth     =   2 
      X1              =   -15 
      X2              =   5640 
      Y1              =   60 
      Y2              =   120 
   End 
   Begin VB.Line Line1  
      BorderColor     =   &H00808080& 
      BorderWidth     =   2 
      X1              =   -15 
      X2              =   6000 
      Y1              =   30 
      Y2              =   45 
   End 
End 
Attribute VB_Name = "FrmNianJi" 
Attribute VB_GlobalNameSpace = False 
Attribute VB_Creatable = False 
Attribute VB_PredeclaredId = True 
Attribute VB_Exposed = False 
 
Option Explicit 
 
Private Sub Command1_Click() 
 Unload Me 
End Sub 
 
Private Sub Command2_Click() 
   Dim sql As String 
   Dim adoRs As Recordset 
   If DGNianJi.ApproxCount = 0 Then Exit Sub 
   Set adoRs = New Recordset 
   sql = "select id from question where nianjiid=" + DGNianJi.Columns(0).Text 
   adoRs.Open sql, DB, adOpenStatic, adLockOptimistic 
   If adoRs.RecordCount > 0 Then 
     MsgBox "对不起,现在问题库里有这个年级的题目,所以不能删除!" 
     Exit Sub 
    Else 
     If MsgBox("你真的要删除这个年级的信息吗?", vbYesNo + vbExclamation, "问题?") = vbYes Then 
        sql = "delete from nianji where id=" + DGNianJi.Columns(0).Text 
        DB.Execute sql 
        TXTName.Text = "" 
        Form_Load 
     End If 
   End If 
   adoRs.Close 
End Sub 
 
Private Sub Command3_Click() 
 On Error GoTo myerror 
 If TXTName = "" Then 
   MsgBox "请输入年级名称!" 
   TXTName.SetFocus 
   Exit Sub 
 End If 
Dim sql As String 
Dim TempRs As Recordset 
Set TempRs = New Recordset 
'判断是否已经有了该年级 
sql = "select xuhao from nianji where name='" + TXTName.Text + "'" 
TempRs.Open sql, DB, adOpenStatic, adLockOptimistic 
If TempRs.RecordCount > 0 Then 
  MsgBox "该年级已经存在,请重新输入!", 48, "提示" 
  TXTName.SetFocus 
  SendKeys "{Home}+{end}" 
  Exit Sub 
End If 
TempRs.Close 
sql = "select xuhao from nianji where xuhao=" & TxTNum.Text 
TempRs.Open sql, DB, adOpenStatic, adLockOptimistic 
If TempRs.RecordCount > 0 Then 
  MsgBox "该年级序号的年级已经存在,请重新输入!" + vbCrLf + "<年级序号>是指该年级名称代表的实际年级,比如:一年级序号是1,二年级序号是2" + vbCrLf + "该版本不支持相同序号的年级存在,比如不能有初一和高一同时存在!" 
  TxTNum.SetFocus 
  SendKeys "{home}+{end}" 
  Exit Sub 
End If 
   '添加年级 
 sql = "insert into nianji (id,name,xuhao,banshu) values (" + Int2Str(GetAutoID("nianji")) + ",'" + TXTName.Text + "'," + TxTNum.Text + "," + TXTCount.Text + ")" 
 DB.Execute sql 
 Form_Load 
 Exit Sub 
myerror: 
 MsgBox err.Description 
End Sub 
 
Private Sub Command4_Click() 
 On Error GoTo myerror 
  Dim XHYesNo As Boolean '表示序号是否存在 
 If DGNianJi.Row < 0 Then 
   MsgBox "请选择年级信息!" 
   Exit Sub 
 End If 
 If TXTName = "" Then 
   MsgBox "请输入年级名称!" 
   TXTName.SetFocus 
   Exit Sub 
 End If 
 Dim sql As String 
Dim TempRs As Recordset 
Set TempRs = New Recordset 
 
sql = "select xuhao from nianji where xuhao=" & TxTNum.Text 
TempRs.Open sql, DB, adOpenStatic, adLockOptimistic 
If TempRs.RecordCount > 0 Then 
  XHYesNo = True 
End If 
TempRs.Close 
 
'判断是否已经有了该年级 
sql = "select xuhao from nianji where name='" + TXTName.Text + "'" 
TempRs.Open sql, DB, adOpenStatic, adLockOptimistic 
 
If TempRs.RecordCount > 0 Then 
  If MsgBox("该年级名称已经存在,是否只修改年级序号和班数?", vbYesNo + 48, "提示") = vbYes Then 
        '修改年级信息 
    If XHYesNo = True Then 
        If MsgBox("该年级序号的年级已经存在,请重新输入!" + vbCrLf + "<年级序号>是指该年级名称代表的实际年级,比如:一年级序号是1,二年级序号是2" + vbCrLf + "该版本不支持相同序号的年级存在,比如不能有初一和高一同时存在!" + vbCrLf + "你是否只修改班数?", vbYesNo + 48, "提示") = vbYes Then 
          sql = "update nianji set banshu=" + TXTCount.Text + " where id=" + DGNianJi.Columns(0).Text 
          DB.Execute sql 
          Form_Load 
          Exit Sub 
        Else 
          Exit Sub 
        End If 
      Else 
        sql = "update nianji set xuhao=" + TxTNum.Text + ",banshu=" + TXTCount.Text + " where id=" + DGNianJi.Columns(0).Text 
        DB.Execute sql 
        Form_Load 
        Exit Sub 
    End If 
     
   Else 
     Exit Sub 
  End If 
End If 
TempRs.Close 
 
If XHYesNo = True Then 
  MsgBox "该年级序号的年级已经存在,请重新输入!" + vbCrLf + "<年级序号>是指该年级名称代表的实际年级,比如:一年级序号是1,二年级序号是2" + vbCrLf + "该版本不支持相同序号的年级存在,比如不能有初一和高一同时存在!" 
  TxTNum.SetFocus 
  SendKeys "{home}+{end}" 
  Exit Sub 
End If 
   '修改年级信息 
 sql = "update nianji set name='" + TXTName + "',xuhao=" + TxTNum.Text + ",banshu=" + TXTCount.Text + " where id=" + DGNianJi.Columns(0).Text 
 DB.Execute sql 
 Form_Load 
 Exit Sub 
myerror: 
 MsgBox err.Description 
End Sub 
 
Private Sub DGnianji_RowColChange(LastRow As Variant, ByVal LastCol As Integer) 
 If DGNianJi.ApproxCount <= 0 Then Exit Sub 
 
 TXTName.Text = DGNianJi.Columns(1).Text 
 TxTNum.Text = DGNianJi.Columns(2).Text 
 TXTCount.Text = DGNianJi.Columns(3).Text 
End Sub 
 
Private Sub Form_Load() 
  '检索年级数据 
  Dim sql As String 
  Dim adoRs As Recordset 
  Set adoRs = New Recordset 
  sql = "select id as 年级ID,name as 年级名称,xuhao as 年级序号,banshu as 班级数 from nianji" 
  adoRs.Open sql, DB, adOpenStatic, adLockOptimistic 
  Set DGNianJi.DataSource = adoRs 
   
End Sub 
 
Private Sub Label4_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