www.pudn.com > Pepsi_five.rar > FrmSetPrTy.frm


VERSION 5.00 
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX" 
Begin VB.Form FrmSetPrTy  
   Caption         =   "物品类别设置" 
   ClientHeight    =   5895 
   ClientLeft      =   60 
   ClientTop       =   345 
   ClientWidth     =   5205 
   Icon            =   "FrmSetPrTy.frx":0000 
   LinkTopic       =   "Form1" 
   MDIChild        =   -1  'True 
   ScaleHeight     =   5895 
   ScaleWidth      =   5205 
   Begin VB.Frame Frame2  
      Height          =   2595 
      Left            =   0 
      TabIndex        =   8 
      Top             =   3300 
      Width           =   5180 
      Begin VB.TextBox txttype_name  
         DataField       =   "type_name" 
         DataMember      =   "ComProType" 
         DataSource      =   "DEjxc" 
         Enabled         =   0   'False 
         Height          =   285 
         Left            =   1410 
         TabIndex        =   14 
         Top             =   1025 
         Width           =   3300 
      End 
      Begin VB.TextBox txttype_id  
         DataField       =   "type_id" 
         DataMember      =   "ComProType" 
         DataSource      =   "DEjxc" 
         Enabled         =   0   'False 
         Height          =   285 
         Left            =   1410 
         MaxLength       =   4 
         TabIndex        =   12 
         Top             =   645 
         Width           =   570 
      End 
      Begin VB.CommandButton CmdAct  
         Caption         =   "恢复(&U)" 
         Enabled         =   0   'False 
         Height          =   315 
         Index           =   1 
         Left            =   2880 
         TabIndex        =   10 
         Top             =   1680 
         Width           =   1275 
      End 
      Begin VB.CommandButton CmdAct  
         Caption         =   "保存(&S)" 
         Enabled         =   0   'False 
         Height          =   315 
         Index           =   0 
         Left            =   960 
         TabIndex        =   9 
         Top             =   1680 
         Width           =   1275 
      End 
      Begin VB.Label lblFieldLabel  
         Alignment       =   1  'Right Justify 
         AutoSize        =   -1  'True 
         Caption         =   "类别名称:" 
         Height          =   180 
         Index           =   1 
         Left            =   570 
         TabIndex        =   13 
         Top             =   1065 
         Width           =   810 
      End 
      Begin VB.Label lblFieldLabel  
         Alignment       =   1  'Right Justify 
         AutoSize        =   -1  'True 
         Caption         =   "类别编号:" 
         Height          =   180 
         Index           =   0 
         Left            =   570 
         TabIndex        =   11 
         Top             =   690 
         Width           =   810 
      End 
   End 
   Begin VB.Frame Frame1  
      Height          =   3375 
      Left            =   0 
      TabIndex        =   0 
      Top             =   -60 
      Width           =   5175 
      Begin VB.CommandButton CmdDep  
         Caption         =   "退出(&X)" 
         Height          =   315 
         Index           =   5 
         Left            =   3540 
         TabIndex        =   7 
         Top             =   2940 
         Width           =   1275 
      End 
      Begin VB.CommandButton CmdDep  
         Caption         =   "列表(&P)" 
         Height          =   315 
         Index           =   4 
         Left            =   3540 
         TabIndex        =   6 
         Top             =   2388 
         Width           =   1275 
      End 
      Begin VB.CommandButton CmdDep  
         Caption         =   "删除(&D)" 
         Height          =   315 
         Index           =   3 
         Left            =   3540 
         TabIndex        =   5 
         Top             =   1836 
         Width           =   1275 
      End 
      Begin VB.CommandButton CmdDep  
         Caption         =   "查询(&F)" 
         Height          =   315 
         Index           =   2 
         Left            =   3540 
         TabIndex        =   4 
         Top             =   1284 
         Width           =   1275 
      End 
      Begin VB.CommandButton CmdDep  
         Caption         =   "编辑(&E)" 
         Height          =   315 
         Index           =   1 
         Left            =   3540 
         TabIndex        =   3 
         Top             =   732 
         Width           =   1275 
      End 
      Begin VB.CommandButton CmdDep  
         Caption         =   "增加(&N)" 
         Height          =   315 
         Index           =   0 
         Left            =   3540 
         TabIndex        =   2 
         Top             =   180 
         Width           =   1275 
      End 
      Begin MSDataGridLib.DataGrid DataGrid1  
         Bindings        =   "FrmSetPrTy.frx":0442 
         Height          =   3075 
         Left            =   60 
         TabIndex        =   1 
         Top             =   180 
         Width           =   3195 
         _ExtentX        =   5636 
         _ExtentY        =   5424 
         _Version        =   393216 
         AllowUpdate     =   0   'False 
         AllowArrows     =   -1  'True 
         HeadLines       =   1 
         RowHeight       =   15 
         TabAcrossSplits =   -1  'True 
         TabAction       =   2 
         WrapCellPointer =   -1  'True 
         FormatLocked    =   -1  'True 
         BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}  
            Name            =   "宋体" 
            Size            =   9 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}  
            Name            =   "宋体" 
            Size            =   9 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         DataMember      =   "ComProType" 
         ColumnCount     =   2 
         BeginProperty Column00  
            DataField       =   "type_id" 
            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       =   "type_name" 
            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  
            BeginProperty Column00  
               ColumnAllowSizing=   0   'False 
               ColumnWidth     =   794.835 
            EndProperty 
            BeginProperty Column01  
               ColumnAllowSizing=   0   'False 
               ColumnWidth     =   2085.166 
            EndProperty 
         EndProperty 
      End 
   End 
End 
Attribute VB_Name = "FrmSetPrTy" 
Attribute VB_GlobalNameSpace = False 
Attribute VB_Creatable = False 
Attribute VB_PredeclaredId = True 
Attribute VB_Exposed = False 
Option Explicit 
Private rsProType As ADODB.Recordset 
Private strMaxNum As String 
Private blnIsSQL As Boolean 
 
Private Sub CmdAct_Click(Index As Integer) 
    On Error GoTo Err: 
    With rsProType 
        Select Case Index 
            Case 0 
                .UpdateBatch 
                .MoveLast 
            Case 1 
                .CancelUpdate 
                If .RecordCount <> 0 Then 
                    .MoveFirst 
                End If 
        End Select 
    End With 
    Call IsEdit(False) 
    Me.DataGrid1.Refresh 
    Exit Sub 
Err: 
    If Err.Number = -2147467259 Then 
        MsgBox "物品类别编号重复!请重新录入新的物品类别编号!", vbCritical, "错误" 
    End If 
End Sub 
 
Private Sub CmdDep_Click(Index As Integer) 
    Dim intAnswer As Integer 
    Select Case Index 
        Case 0 
            Call PrTyAddNew 
        Case 1 
            Call IsEdit(True) 
            Me.txttype_id.SetFocus 
        Case 2 
            FrmSql.intNumField = 2 
            FrmSql.Show vbModal 
            Select Case FrmSql.intNumField 
                Case -1 
                    blnIsSQL = False 
                    CmdDep(0).Enabled = True 
                    CmdDep(3).Enabled = True 
                    rsProType.Filter = Me.DataGrid1.Columns.Item(0).DataField & _ 
                    "<>''" 
                Case -2 
                Case Else 
                    blnIsSQL = True 
                    CmdDep(0).Enabled = False 
                    CmdDep(3).Enabled = False 
                    rsProType.Filter = Me.DataGrid1.Columns.Item(FrmSql.intNumField).DataField & _ 
                    " like '*" & FrmSql.strSqlField & "*'" 
            End Select 
        Case 3 
            intAnswer = MsgBox("确认删除当前记录吗?", vbYesNo + vbQuestion, "删除确认") 
            If intAnswer = vbYes Then 
                With rsProType 
                    .Delete 
                    .UpdateBatch 
                    If .RecordCount <> 0 Then 
                        .MoveFirst 
                    Else 
                        For intAnswer = 1 To 4 
                            CmdDep(intAnswer).Enabled = False 
                        Next 
                    End If 
                End With 
            End If 
        Case 4 
             
        Case 5 
            Unload Me 
    End Select 
End Sub 
 
Private Sub Form_Load() 
    intNumWindows = OpenWindow(intNumWindows) 
    Me.Height = 6300 
    Me.Width = 5325 
    Call SetFormStu(Me, frmMain) 
    Set rsProType = DEjxc.rsComProType 
    Call IsEdit(False) 
End Sub 
 
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) 
    If CmdDep(5).Enabled = False Then 
        MsgBox "请先退出编辑状态后再退出该程序!", , "提示" 
        Cancel = True 
    End If 
End Sub 
 
Private Sub Form_Unload(Cancel As Integer) 
    intNumWindows = Closewindow(intNumWindows) 
    rsProType.Filter = Me.DataGrid1.Columns.Item(0).DataField & "<>''" 
    rsProType.Close 
    Set rsProType = Nothing 
End Sub 
 
Private Sub PrTyAddNew() 
    Dim strSQL As String 
    With rsProType 
        'If .RecordCount = 0 Then 
        '    strMaxNum = 0 
        'Else 
        '    .MoveLast 
        '    strMaxNum = !type_id 
        'End If 
        .AddNew "type_id", "" 
        Call IsEdit(True) 
        Me.txttype_id.SetFocus 
    End With 
End Sub 
 
Private Sub IsEdit(blnIsEdit As Boolean) 
    Dim intNum As Integer 
    Me.txttype_id.Enabled = blnIsEdit 
    Me.txttype_name.Enabled = blnIsEdit 
    For intNum = 0 To 1 
        Me.CmdAct(intNum).Enabled = blnIsEdit 
    Next 
    For intNum = 0 To 5 
        Me.CmdDep(intNum).Enabled = Not blnIsEdit 
    Next 
    If blnIsSQL = True Then 
        CmdDep(0).Enabled = False 
        CmdDep(3).Enabled = False 
    End If 
    If rsProType.RecordCount = 0 Then 
        For intNum = 1 To 4 
            Me.CmdDep(intNum).Enabled = False 
        Next 
    End If 
End Sub 
 
Private Sub txttype_id_KeyPress(KeyAscii As Integer) 
    Dim strValid As String 
    strValid = "0123456789" 
    If KeyAscii > 26 Then 
        If InStr(strValid, Chr(KeyAscii)) = 0 Then 
            KeyAscii = 0 
        End If 
    End If 
    If KeyAscii = 13 Then txttype_name.SetFocus 
End Sub