www.pudn.com > jxc001.rar > FrmSetPro.frm


VERSION 5.00 
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX" 
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX" 
Begin VB.Form FrmSetPro  
   Caption         =   "物品设置" 
   ClientHeight    =   6600 
   ClientLeft      =   60 
   ClientTop       =   345 
   ClientWidth     =   7725 
   Icon            =   "FrmSetPro.frx":0000 
   LinkTopic       =   "Form1" 
   MDIChild        =   -1  'True 
   ScaleHeight     =   6600 
   ScaleWidth      =   7725 
   Begin VB.Frame Frame2  
      Height          =   3240 
      Left            =   0 
      TabIndex        =   8 
      Top             =   3300 
      Width           =   7695 
      Begin MSDataListLib.DataCombo DCboPrty  
         Bindings        =   "FrmSetPro.frx":0442 
         DataField       =   "type_id" 
         DataMember      =   "ComProduct" 
         DataSource      =   "DEjxc" 
         Height          =   330 
         Left            =   2340 
         TabIndex        =   20 
         Top             =   360 
         Width           =   1395 
         _ExtentX        =   2461 
         _ExtentY        =   582 
         _Version        =   393216 
         Enabled         =   0   'False 
         Style           =   2 
         ListField       =   "type_name" 
         BoundColumn     =   "type_id" 
         Text            =   "DataCombo1" 
         Object.DataMember      =   "ComProType" 
      End 
      Begin VB.TextBox txtunit  
         DataField       =   "unit" 
         DataMember      =   "ComProduct" 
         DataSource      =   "DEjxc" 
         Enabled         =   0   'False 
         Height          =   330 
         Left            =   2340 
         TabIndex        =   19 
         Top             =   2115 
         Width           =   660 
      End 
      Begin VB.TextBox txtproduct_model  
         DataField       =   "product_model" 
         DataMember      =   "ComProduct" 
         DataSource      =   "DEjxc" 
         Enabled         =   0   'False 
         Height          =   330 
         Left            =   2355 
         TabIndex        =   16 
         Top             =   1665 
         Width           =   2970 
      End 
      Begin VB.TextBox txtproduct_name  
         DataField       =   "product_name" 
         DataMember      =   "ComProduct" 
         DataSource      =   "DEjxc" 
         Enabled         =   0   'False 
         Height          =   330 
         Left            =   2355 
         TabIndex        =   14 
         Top             =   1215 
         Width           =   3375 
      End 
      Begin VB.TextBox txtp_id  
         DataField       =   "p_id" 
         DataMember      =   "ComProduct" 
         DataSource      =   "DEjxc" 
         Enabled         =   0   'False 
         Height          =   330 
         Left            =   2340 
         TabIndex        =   12 
         Top             =   780 
         Width           =   1320 
      End 
      Begin VB.CommandButton CmdAct  
         Caption         =   "恢复(&U)" 
         Enabled         =   0   'False 
         Height          =   315 
         Index           =   1 
         Left            =   4380 
         TabIndex        =   10 
         Top             =   2700 
         Width           =   1275 
      End 
      Begin VB.CommandButton CmdAct  
         Caption         =   "保存(&S)" 
         Enabled         =   0   'False 
         Height          =   315 
         Index           =   0 
         Left            =   2460 
         TabIndex        =   9 
         Top             =   2700 
         Width           =   1275 
      End 
      Begin VB.Label lblFieldLabel  
         Alignment       =   1  'Right Justify 
         AutoSize        =   -1  'True 
         Caption         =   "单位:" 
         Height          =   180 
         Index           =   4 
         Left            =   1875 
         TabIndex        =   18 
         Top             =   2220 
         Width           =   450 
      End 
      Begin VB.Label lblFieldLabel  
         Alignment       =   1  'Right Justify 
         AutoSize        =   -1  'True 
         Caption         =   "物品类别:" 
         Height          =   180 
         Index           =   3 
         Left            =   1500 
         TabIndex        =   17 
         Top             =   480 
         Width           =   810 
      End 
      Begin VB.Label lblFieldLabel  
         Alignment       =   1  'Right Justify 
         AutoSize        =   -1  'True 
         Caption         =   "规格型号:" 
         Height          =   180 
         Index           =   2 
         Left            =   1515 
         TabIndex        =   15 
         Top             =   1770 
         Width           =   810 
      End 
      Begin VB.Label lblFieldLabel  
         Alignment       =   1  'Right Justify 
         AutoSize        =   -1  'True 
         Caption         =   "物品名称:" 
         Height          =   180 
         Index           =   1 
         Left            =   1500 
         TabIndex        =   13 
         Top             =   1320 
         Width           =   810 
      End 
      Begin VB.Label lblFieldLabel  
         Alignment       =   1  'Right Justify 
         AutoSize        =   -1  'True 
         Caption         =   "物品编号:" 
         Height          =   180 
         Index           =   0 
         Left            =   1515 
         TabIndex        =   11 
         Top             =   885 
         Width           =   810 
      End 
   End 
   Begin VB.Frame Frame1  
      Height          =   3375 
      Left            =   0 
      TabIndex        =   0 
      Top             =   -60 
      Width           =   7695 
      Begin VB.CommandButton CmdDep  
         Caption         =   "退出(&X)" 
         Height          =   315 
         Index           =   5 
         Left            =   6180 
         TabIndex        =   7 
         Top             =   2940 
         Width           =   1275 
      End 
      Begin VB.CommandButton CmdDep  
         Caption         =   "列表(&P)" 
         Height          =   315 
         Index           =   4 
         Left            =   6180 
         TabIndex        =   6 
         Top             =   2385 
         Width           =   1275 
      End 
      Begin VB.CommandButton CmdDep  
         Caption         =   "删除(&D)" 
         Height          =   315 
         Index           =   3 
         Left            =   6180 
         TabIndex        =   5 
         Top             =   1830 
         Width           =   1275 
      End 
      Begin VB.CommandButton CmdDep  
         Caption         =   "查询(&F)" 
         Height          =   315 
         Index           =   2 
         Left            =   6180 
         TabIndex        =   4 
         Top             =   1290 
         Width           =   1275 
      End 
      Begin VB.CommandButton CmdDep  
         Caption         =   "编辑(&E)" 
         Height          =   315 
         Index           =   1 
         Left            =   6180 
         TabIndex        =   3 
         Top             =   735 
         Width           =   1275 
      End 
      Begin VB.CommandButton CmdDep  
         Caption         =   "增加(&N)" 
         Height          =   315 
         Index           =   0 
         Left            =   6180 
         TabIndex        =   2 
         Top             =   180 
         Width           =   1275 
      End 
      Begin MSDataGridLib.DataGrid DataGrid1  
         Bindings        =   "FrmSetPro.frx":0461 
         Height          =   3075 
         Left            =   60 
         TabIndex        =   1 
         Top             =   180 
         Width           =   5895 
         _ExtentX        =   10398 
         _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      =   "ComProduct" 
         ColumnCount     =   5 
         BeginProperty Column00  
            DataField       =   "p_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       =   "product_name" 
            Caption         =   "物品名称" 
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}  
               Type            =   0 
               Format          =   "" 
               HaveTrueFalseNull=   0 
               FirstDayOfWeek  =   0 
               FirstWeekOfYear =   0 
               LCID            =   2052 
               SubFormatType   =   0 
            EndProperty 
         EndProperty 
         BeginProperty Column02  
            DataField       =   "product_model" 
            Caption         =   "规格型号" 
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}  
               Type            =   0 
               Format          =   "" 
               HaveTrueFalseNull=   0 
               FirstDayOfWeek  =   0 
               FirstWeekOfYear =   0 
               LCID            =   2052 
               SubFormatType   =   0 
            EndProperty 
         EndProperty 
         BeginProperty Column03  
            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 Column04  
            DataField       =   "unit" 
            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     =   900.284 
            EndProperty 
            BeginProperty Column01  
               ColumnAllowSizing=   0   'False 
               ColumnWidth     =   1800 
            EndProperty 
            BeginProperty Column02  
               ColumnAllowSizing=   0   'False 
               ColumnWidth     =   1200.189 
            EndProperty 
            BeginProperty Column03  
               ColumnAllowSizing=   0   'False 
               ColumnWidth     =   794.835 
            EndProperty 
            BeginProperty Column04  
               ColumnAllowSizing=   0   'False 
               ColumnWidth     =   555.024 
            EndProperty 
         EndProperty 
      End 
   End 
End 
Attribute VB_Name = "FrmSetPro" 
Attribute VB_GlobalNameSpace = False 
Attribute VB_Creatable = False 
Attribute VB_PredeclaredId = True 
Attribute VB_Exposed = False 
Option Explicit 
Private rsProduct As ADODB.Recordset 
Private rsProMat As ADODB.Recordset 
Private cmProduct As ADODB.Command 
Private strMaxNum As String 
Private blnAddOrEdit As Boolean 
 
Private Sub CmdAct_Click(Index As Integer) 
    Dim strSQL As String 
    With rsProduct 
        Select Case Index 
            Case 0 
                If txtp_id.Text = "" Then 
                    MsgBox "物品类别与编号不能为空!", vbCritical, "录入错" 
                    Exit Sub 
                End If 
                .UpdateBatch 
                If blnAddOrEdit = True Then 
                    rsProMat.Open 
                    rsProMat.AddNew "p_id", Me.txtp_id.Text 
                    rsProMat.UpdateBatch 
                    rsProMat.Close 
                End If 
                .Filter = "p_id<>''" 
                .MoveLast 
            Case 1 
                .CancelUpdate 
                .Filter = "p_id<>''" 
                If .RecordCount <> 0 Then 
                    .MoveFirst 
                End If 
        End Select 
    End With 
    Call IsEdit(False) 
    Me.DataGrid1.Refresh 
End Sub 
 
Private Sub CmdDep_Click(Index As Integer) 
    Dim intAnswer As Integer 
    Dim strSQL As String 
    Select Case Index 
        Case 0 
            blnAddOrEdit = True 
            Call ProAddNew 
        Case 1 
            blnAddOrEdit = False 
            Call IsEdit(True) 
            Me.DCboPrty.Enabled = False 
            Me.txtproduct_name.SetFocus 
        Case 2 
            FrmSql.intNumField = 5 
            FrmSql.Show vbModal 
            Select Case FrmSql.intNumField 
                Case -1 
                    CmdDep(0).Enabled = True 
                    CmdDep(3).Enabled = True 
                    rsProduct.Filter = Me.DataGrid1.Columns.Item(0).DataField & _ 
                    "<>''" 
                Case -2 
                Case Else 
                    CmdDep(0).Enabled = False 
                    CmdDep(3).Enabled = False 
                    rsProduct.Filter = Me.DataGrid1.Columns.Item(FrmSql.intNumField).DataField & _ 
                    " like '*" & FrmSql.strSqlField & "*'" 
            End Select 
        Case 3 
            intAnswer = MsgBox("确认删除当前记录吗?", vbYesNo + vbQuestion, "删除确认") 
            If intAnswer = vbYes Then 
                With rsProduct 
                    strSQL = "delete from mat_head where p_id='" & Me.txtp_id.Text & "'" 
                    cmProduct.CommandText = strSQL 
                    cmProduct.Execute 
                    .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 DCboPrty_KeyPress(KeyAscii As Integer) 
    If KeyAscii = 13 Then 
        If Not IsNull(Me.DCboPrty.SelectedItem) Then 
            With rsProduct 
                .Filter = "type_id='" & Me.DCboPrty.BoundText & "'" 
                If .RecordCount = 1 Then 
                    strMaxNum = Me.DCboPrty.BoundText & "0000" 
                Else 
                    .MoveLast 
                    .MovePrevious 
                    strMaxNum = !p_id 
                    .MoveNext 
                End If 
                Me.txtp_id = Format(CLng(strMaxNum) + 1, "0#######") 
                .MovePrevious 
                .MoveNext 
            End With 
        End If 
        Me.txtproduct_name.SetFocus 
    End If 
End Sub 
 
Private Sub Form_Load() 
    intNumWindows = OpenWindow(intNumWindows) 
    Me.Height = 7005 
    Me.Width = 7845 
    Call SetFormStu(Me, frmMain) 
    Set rsProduct = DEjxc.rsComProduct 
    Set rsProMat = DEjxc.rsComMatHead 
    Set cmProduct = New ADODB.Command 
    cmProduct.ActiveConnection = DEjxc.Conjxc 
    cmProduct.CommandType = adCmdText 
    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) 
    Dim strSQL As String 
    intNumWindows = Closewindow(intNumWindows) 
    rsProduct.Filter = Me.DataGrid1.Columns.Item(0).DataField & "<>''" 
    strSQL = "update mat_head set qty=0 where isnull(qty)=true" 
    cmProduct.CommandText = strSQL 
    cmProduct.Execute 
    strSQL = "update mat_head set price=0 where isnull(price)=true" 
    cmProduct.CommandText = strSQL 
    cmProduct.Execute 
    rsProduct.Close 
    Set rsProduct = Nothing 
    Set rsProMat = Nothing 
    Set cmProduct = Nothing 
End Sub 
 
Private Sub ProAddNew() 
    Dim strSQL As String 
    With rsProduct 
        .AddNew 
        Call IsEdit(True) 
        Me.DCboPrty.SetFocus 
    End With 
End Sub 
 
Private Sub IsEdit(blnIsEdit As Boolean) 
    Dim intNum As Integer 
    Me.txtproduct_model.Enabled = blnIsEdit 
    Me.txtproduct_name.Enabled = blnIsEdit 
    Me.txtunit.Enabled = blnIsEdit 
    Me.DCboPrty.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 rsProduct.RecordCount = 0 Then 
        For intNum = 1 To 4 
            Me.CmdDep(intNum).Enabled = False 
        Next 
    End If 
End Sub 
 
Private Sub txtproduct_model_KeyPress(KeyAscii As Integer) 
    If KeyAscii = 13 Then Me.txtunit.SetFocus 
End Sub 
 
Private Sub txtproduct_name_KeyPress(KeyAscii As Integer) 
    If KeyAscii = 13 Then Me.txtproduct_model.SetFocus 
End Sub