www.pudn.com > Pepsi_five.rar > FrmOtherEdit.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 FrmOtherEdit  
   Caption         =   "其它入库单编辑" 
   ClientHeight    =   6900 
   ClientLeft      =   60 
   ClientTop       =   345 
   ClientWidth     =   7725 
   Icon            =   "FrmOtherEdit.frx":0000 
   LinkTopic       =   "Form1" 
   MDIChild        =   -1  'True 
   ScaleHeight     =   6900 
   ScaleWidth      =   7725 
   Begin VB.Frame Frame2  
      Height          =   3900 
      Left            =   0 
      TabIndex        =   8 
      Top             =   2940 
      Width           =   7695 
      Begin MSDataListLib.DataCombo DCboOtRid  
         Bindings        =   "FrmOtherEdit.frx":0442 
         DataField       =   "other_rid" 
         DataMember      =   "ComOtHA" 
         DataSource      =   "DEjxc" 
         Height          =   330 
         Left            =   945 
         TabIndex        =   29 
         Top             =   720 
         Width           =   1815 
         _ExtentX        =   3201 
         _ExtentY        =   582 
         _Version        =   393216 
         Enabled         =   0   'False 
         Style           =   2 
         ListField       =   "department_name" 
         BoundColumn     =   "department_id" 
         Text            =   "" 
         Object.DataMember      =   "ComDepartment" 
      End 
      Begin MSDataListLib.DataCombo DCboOtherType  
         Bindings        =   "FrmOtherEdit.frx":045E 
         DataField       =   "other_type_id" 
         DataMember      =   "ComOtHA" 
         DataSource      =   "DEjxc" 
         Height          =   330 
         Left            =   960 
         TabIndex        =   28 
         Top             =   270 
         Width           =   1575 
         _ExtentX        =   2778 
         _ExtentY        =   582 
         _Version        =   393216 
         Enabled         =   0   'False 
         Style           =   2 
         ListField       =   "type_name" 
         BoundColumn     =   "type_id" 
         Text            =   "" 
         Object.DataMember      =   "ComOrderType" 
      End 
      Begin VB.TextBox txtother_demo  
         DataField       =   "other_demo" 
         DataMember      =   "ComOtHA" 
         DataSource      =   "DEjxc" 
         Enabled         =   0   'False 
         Height          =   330 
         Left            =   4980 
         TabIndex        =   27 
         Top             =   720 
         Width           =   2535 
      End 
      Begin VB.TextBox txtother_car  
         DataField       =   "other_car" 
         DataMember      =   "ComOtHA" 
         DataSource      =   "DEjxc" 
         Enabled         =   0   'False 
         Height          =   330 
         Left            =   3345 
         TabIndex        =   25 
         Top             =   720 
         Width           =   1050 
      End 
      Begin VB.TextBox txtother_maker  
         DataField       =   "other_maker" 
         DataMember      =   "ComOtHA" 
         DataSource      =   "DEjxc" 
         Enabled         =   0   'False 
         Height          =   330 
         Left            =   6825 
         TabIndex        =   23 
         Top             =   270 
         Width           =   660 
      End 
      Begin VB.TextBox txtother_date  
         DataField       =   "other_date" 
         DataMember      =   "ComOtHA" 
         DataSource      =   "DEjxc" 
         Enabled         =   0   'False 
         Height          =   330 
         Left            =   5025 
         TabIndex        =   19 
         Top             =   270 
         Width           =   1020 
      End 
      Begin VB.TextBox txtother_id  
         DataField       =   "other_id" 
         DataMember      =   "ComOtHA" 
         DataSource      =   "DEjxc" 
         Enabled         =   0   'False 
         Height          =   330 
         Left            =   3465 
         TabIndex        =   17 
         Top             =   270 
         Width           =   945 
      End 
      Begin VB.TextBox Txtgrid2  
         Height          =   270 
         Left            =   1200 
         TabIndex        =   14 
         Top             =   2100 
         Visible         =   0   'False 
         Width           =   1215 
      End 
      Begin VB.CommandButton CmdAct  
         Caption         =   "删除明细(&M)" 
         Enabled         =   0   'False 
         Height          =   315 
         Index           =   3 
         Left            =   6060 
         TabIndex        =   13 
         Top             =   3360 
         Width           =   1275 
      End 
      Begin VB.CommandButton CmdAct  
         Caption         =   "增加明细(&A)" 
         Enabled         =   0   'False 
         Height          =   315 
         Index           =   2 
         Left            =   4180 
         TabIndex        =   12 
         Top             =   3360 
         Width           =   1275 
      End 
      Begin MSDataGridLib.DataGrid DataGrid2  
         Bindings        =   "FrmOtherEdit.frx":047A 
         Height          =   1575 
         Left            =   420 
         TabIndex        =   11 
         Top             =   1260 
         Width           =   6855 
         _ExtentX        =   12091 
         _ExtentY        =   2778 
         _Version        =   393216 
         AllowUpdate     =   0   'False 
         Enabled         =   -1  'True 
         HeadLines       =   1 
         RowHeight       =   17 
         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      =   "ComOrdDA" 
         ColumnCount     =   5 
         BeginProperty Column00  
            DataField       =   "order_id" 
            Caption         =   "order_id" 
            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       =   "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 Column02  
            DataField       =   "qty" 
            Caption         =   "数量" 
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}  
               Type            =   1 
               Format          =   "#,##0.0000" 
               HaveTrueFalseNull=   0 
               FirstDayOfWeek  =   0 
               FirstWeekOfYear =   0 
               LCID            =   2052 
               SubFormatType   =   0 
            EndProperty 
         EndProperty 
         BeginProperty Column03  
            DataField       =   "unit_price" 
            Caption         =   "单价" 
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}  
               Type            =   1 
               Format          =   "0.00" 
               HaveTrueFalseNull=   0 
               FirstDayOfWeek  =   0 
               FirstWeekOfYear =   0 
               LCID            =   2052 
               SubFormatType   =   0 
            EndProperty 
         EndProperty 
         BeginProperty Column04  
            DataField       =   "price" 
            Caption         =   "金额" 
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}  
               Type            =   1 
               Format          =   "#,##0.00" 
               HaveTrueFalseNull=   0 
               FirstDayOfWeek  =   0 
               FirstWeekOfYear =   0 
               LCID            =   2052 
               SubFormatType   =   0 
            EndProperty 
         EndProperty 
         SplitCount      =   1 
         BeginProperty Split0  
            BeginProperty Column00  
               ColumnAllowSizing=   0   'False 
               Object.Visible         =   0   'False 
               ColumnWidth     =   1275.024 
            EndProperty 
            BeginProperty Column01  
               Alignment       =   1 
               ColumnAllowSizing=   0   'False 
               ColumnWidth     =   1184.882 
            EndProperty 
            BeginProperty Column02  
               Alignment       =   1 
               ColumnAllowSizing=   0   'False 
               ColumnWidth     =   1800 
            EndProperty 
            BeginProperty Column03  
               Alignment       =   1 
               ColumnAllowSizing=   0   'False 
               ColumnWidth     =   1500.095 
            EndProperty 
            BeginProperty Column04  
               Alignment       =   1 
               ColumnAllowSizing=   0   'False 
               ColumnWidth     =   1800 
            EndProperty 
         EndProperty 
      End 
      Begin VB.CommandButton CmdAct  
         Caption         =   "恢复(&U)" 
         Enabled         =   0   'False 
         Height          =   315 
         Index           =   1 
         Left            =   2300 
         TabIndex        =   10 
         Top             =   3360 
         Width           =   1275 
      End 
      Begin VB.CommandButton CmdAct  
         Caption         =   "保存(&S)" 
         Enabled         =   0   'False 
         Height          =   315 
         Index           =   0 
         Left            =   420 
         TabIndex        =   9 
         Top             =   3360 
         Width           =   1275 
      End 
      Begin VB.Label lblFieldLabel  
         Alignment       =   1  'Right Justify 
         AutoSize        =   -1  'True 
         Caption         =   "备注:" 
         Height          =   180 
         Index           =   6 
         Left            =   4485 
         TabIndex        =   26 
         Top             =   795 
         Width           =   450 
      End 
      Begin VB.Label lblFieldLabel  
         Alignment       =   1  'Right Justify 
         AutoSize        =   -1  'True 
         Caption         =   "车号:" 
         Height          =   180 
         Index           =   5 
         Left            =   2865 
         TabIndex        =   24 
         Top             =   795 
         Width           =   450 
      End 
      Begin VB.Label lblFieldLabel  
         Alignment       =   1  'Right Justify 
         AutoSize        =   -1  'True 
         Caption         =   "制单人:" 
         Height          =   180 
         Index           =   4 
         Left            =   6165 
         TabIndex        =   22 
         Top             =   375 
         Width           =   630 
      End 
      Begin VB.Label lblFieldLabel  
         Alignment       =   1  'Right Justify 
         AutoSize        =   -1  'True 
         Caption         =   "对方单位:" 
         Height          =   180 
         Index           =   3 
         Left            =   105 
         TabIndex        =   21 
         Top             =   795 
         Width           =   810 
      End 
      Begin VB.Label lblFieldLabel  
         Alignment       =   1  'Right Justify 
         AutoSize        =   -1  'True 
         Caption         =   "单据类型:" 
         Height          =   180 
         Index           =   2 
         Left            =   120 
         TabIndex        =   20 
         Top             =   375 
         Width           =   810 
      End 
      Begin VB.Label lblFieldLabel  
         Alignment       =   1  'Right Justify 
         AutoSize        =   -1  'True 
         Caption         =   "日期:" 
         Height          =   180 
         Index           =   1 
         Left            =   4545 
         TabIndex        =   18 
         Top             =   360 
         Width           =   450 
      End 
      Begin VB.Label lblFieldLabel  
         Alignment       =   1  'Right Justify 
         AutoSize        =   -1  'True 
         Caption         =   "单据编号:" 
         Height          =   180 
         Index           =   0 
         Left            =   2625 
         TabIndex        =   16 
         Top             =   375 
         Width           =   810 
      End 
      Begin VB.Label LblStatus  
         BorderStyle     =   1  'Fixed Single 
         ForeColor       =   &H00FF0000& 
         Height          =   315 
         Left            =   420 
         TabIndex        =   15 
         Top             =   2880 
         Width           =   6855 
      End 
   End 
   Begin VB.Frame Frame1  
      Height          =   2955 
      Left            =   0 
      TabIndex        =   0 
      Top             =   -60 
      Width           =   7695 
      Begin VB.CommandButton CmdDep  
         Caption         =   "退出(&X)" 
         Height          =   315 
         Index           =   5 
         Left            =   6360 
         TabIndex        =   7 
         Top             =   2520 
         Width           =   1275 
      End 
      Begin VB.CommandButton CmdDep  
         Caption         =   "列表(&P)" 
         Height          =   315 
         Index           =   4 
         Left            =   6360 
         TabIndex        =   6 
         Top             =   2052 
         Width           =   1275 
      End 
      Begin VB.CommandButton CmdDep  
         Caption         =   "删除(&D)" 
         Height          =   315 
         Index           =   3 
         Left            =   6360 
         TabIndex        =   5 
         Top             =   1584 
         Width           =   1275 
      End 
      Begin VB.CommandButton CmdDep  
         Caption         =   "查询(&F)" 
         Height          =   315 
         Index           =   2 
         Left            =   6360 
         TabIndex        =   4 
         Top             =   1116 
         Width           =   1275 
      End 
      Begin VB.CommandButton CmdDep  
         Caption         =   "编辑(&E)" 
         Height          =   315 
         Index           =   1 
         Left            =   6360 
         TabIndex        =   3 
         Top             =   648 
         Width           =   1275 
      End 
      Begin VB.CommandButton CmdDep  
         Caption         =   "增加(&N)" 
         Height          =   315 
         Index           =   0 
         Left            =   6360 
         TabIndex        =   2 
         Top             =   180 
         Width           =   1275 
      End 
      Begin MSDataGridLib.DataGrid DataGrid1  
         Bindings        =   "FrmOtherEdit.frx":048E 
         Height          =   2655 
         Left            =   60 
         TabIndex        =   1 
         Top             =   180 
         Width           =   6255 
         _ExtentX        =   11033 
         _ExtentY        =   4683 
         _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      =   "ComOtHA" 
         ColumnCount     =   7 
         BeginProperty Column00  
            DataField       =   "other_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       =   "other_date" 
            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       =   "other_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 Column03  
            DataField       =   "other_rid" 
            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       =   "other_maker" 
            Caption         =   "制单人" 
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}  
               Type            =   0 
               Format          =   "" 
               HaveTrueFalseNull=   0 
               FirstDayOfWeek  =   0 
               FirstWeekOfYear =   0 
               LCID            =   2052 
               SubFormatType   =   0 
            EndProperty 
         EndProperty 
         BeginProperty Column05  
            DataField       =   "other_car" 
            Caption         =   "车号" 
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}  
               Type            =   0 
               Format          =   "" 
               HaveTrueFalseNull=   0 
               FirstDayOfWeek  =   0 
               FirstWeekOfYear =   0 
               LCID            =   2052 
               SubFormatType   =   0 
            EndProperty 
         EndProperty 
         BeginProperty Column06  
            DataField       =   "other_demo" 
            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  
               Alignment       =   1 
               ColumnAllowSizing=   0   'False 
               ColumnWidth     =   854.929 
            EndProperty 
            BeginProperty Column01  
               Alignment       =   1 
               ColumnAllowSizing=   0   'False 
               ColumnWidth     =   794.835 
            EndProperty 
            BeginProperty Column02  
               Alignment       =   1 
               ColumnAllowSizing=   0   'False 
               ColumnWidth     =   794.835 
            EndProperty 
            BeginProperty Column03  
               Alignment       =   1 
               ColumnAllowSizing=   0   'False 
               ColumnWidth     =   794.835 
            EndProperty 
            BeginProperty Column04  
               Alignment       =   1 
               ColumnAllowSizing=   0   'False 
               ColumnWidth     =   599.811 
            EndProperty 
            BeginProperty Column05  
               Alignment       =   1 
               ColumnAllowSizing=   0   'False 
               ColumnWidth     =   900.284 
            EndProperty 
            BeginProperty Column06  
               Alignment       =   1 
               ColumnAllowSizing=   0   'False 
               ColumnWidth     =   1200.189 
            EndProperty 
         EndProperty 
      End 
   End 
End 
Attribute VB_Name = "FrmOtherEdit" 
Attribute VB_GlobalNameSpace = False 
Attribute VB_Creatable = False 
Attribute VB_PredeclaredId = True 
Attribute VB_Exposed = False 
Option Explicit 
Private rsOtHA As ADODB.Recordset 
Private rsOrdDA As ADODB.Recordset 
Private cmOtHA As ADODB.Command 
Private strMaxNum As String 
 
Private Sub CmdAct_Click(Index As Integer) 
    Dim intRow As Integer 
    Dim blnIsTrue As Boolean 
    With rsOtHA 
        Select Case Index 
            Case 0 
                blnIsTrue = SaveValid() 
                If Not blnIsTrue Then 
                    Exit Sub 
                End If 
                With rsOrdDA 
                    If .RecordCount <> 0 Then 
                        .MoveFirst 
                        While Not .EOF 
                            !order_id = Me.txtother_id.Text 
                            .MoveNext 
                        Wend 
                    End If 
                End With 
                rsOrdDA.Filter = "order_id='" & Me.txtother_id.Text & "'" 
                rsOrdDA.UpdateBatch 
                .Filter = "other_id<>''" 
                .UpdateBatch 
                .MoveLast 
                Call IsEdit(False) 
            Case 1 
                rsOrdDA.CancelBatch 
                .Filter = "other_id<>''" 
                If .RecordCount <> 0 Then 
                    .MoveFirst 
                End If 
                .CancelBatch 
                Call IsEdit(False) 
                rsOrdDA.Filter = "order_id='" & Me.txtother_id.Text & "'" 
            Case 2 
                rsOrdDA.AddNew "order_id", Me.txtother_id.Text 
                rsOrdDA.Filter = "order_id='" & Me.txtother_id.Text & "'" 
                rsOrdDA.MoveLast 
                DataGrid2.Col = 1 
                Call IsEdit(True) 
                Call Txtgrid2_Leave 
            Case 3 
                If rsOrdDA.RecordCount <> 0 Then 
                    rsOrdDA.Delete 
                End If 
                If rsOrdDA.RecordCount <> 0 Then 
                    rsOrdDA.MoveFirst 
                    DataGrid2.Col = 1 
                    Call IsEdit(True) 
                    Call Txtgrid2_Leave 
                End If 
        End Select 
    End With 
End Sub 
 
Private Sub CmdDep_Click(Index As Integer) 
    Dim intAnswer As Integer 
    Dim strSQL As String 
    Select Case Index 
        Case 0 
            Call OtHAAddNew 
        Case 1 
            Call IsEdit(True) 
            Me.txtother_id.SetFocus 
            With rsOrdDA 
                If .RecordCount <> 0 Then 
                    .MoveFirst 
                    DataGrid2.Col = 1 
                    Call Txtgrid2_Leave 
                End If 
            End With 
        Case 2 
            FrmSql.intNumField = 7 
            FrmSql.Show vbModal 
            Select Case FrmSql.intNumField 
                Case -1 
                    CmdDep(0).Enabled = True 
                    CmdDep(3).Enabled = True 
                    rsOtHA.Filter = Me.DataGrid1.Columns.Item(0).DataField & _ 
                    "<>''" 
                    rsOrdDA.Filter = "order_id ='" & Me.txtother_id.Text & "'" 
                Case -2 
                Case Else 
                    CmdDep(0).Enabled = False 
                    CmdDep(3).Enabled = False 
                    rsOtHA.Filter = Me.DataGrid1.Columns.Item(FrmSql.intNumField).DataField & _ 
                    " like '*" & FrmSql.strSqlField & "*'" 
                    rsOrdDA.Filter = "order_id ='" & Me.txtother_id.Text & "'" 
            End Select 
        Case 3 
            intAnswer = MsgBox("确认删除当前记录吗?", vbYesNo + vbQuestion, "删除确认") 
            If intAnswer = vbYes Then 
                With rsOtHA 
                    strSQL = "delete from order_detail_a where order_id='" & Me.txtother_id.Text & "'" 
                    cmOtHA.CommandText = strSQL 
                    cmOtHA.Execute 
                    .Delete 
                    .UpdateBatch 
                    If .RecordCount <> 0 Then 
                        .MoveFirst 
                    End If 
                    rsOrdDA.Filter = "order_id ='" & Me.txtother_id.Text & "'" 
                End With 
            End If 
        Case 4 
             
        Case 5 
            Unload Me 
    End Select 
End Sub 
 
Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer) 
    rsOrdDA.Filter = "order_id ='" & Me.txtother_id.Text & "'" 
End Sub 
 
Private Sub DataGrid2_RowColChange(LastRow As Variant, ByVal LastCol As Integer) 
    If CmdDep(2).Enabled = True Then 
        LblStatus.Caption = Product_Status(DataGrid2.Columns(1).Text) 
    End If 
End Sub 
 
Private Sub DCboOtherType_KeyPress(KeyAscii As Integer) 
    If KeyAscii = 13 And (Not IsNull(Me.DCboOtherType.SelectedItem)) Then 
        Me.txtother_id.SetFocus 
    End If 
End Sub 
 
Private Sub DCboOtherType_Validate(Cancel As Boolean) 
    If IsNull(Me.DCboOtherType.SelectedItem) Then 
        Cancel = True 
    End If 
End Sub 
 
Private Sub DCboOtRid_KeyPress(KeyAscii As Integer) 
    If KeyAscii = 13 Then Me.txtother_car.SetFocus 
End Sub 
 
Private Sub Form_Load() 
    intNumWindows = OpenWindow(intNumWindows) 
    Me.Height = 7305 
    Me.Width = 7845 
    Call SetFormStu(Me, frmMain) 
    Set rsOtHA = DEjxc.rsComOtHA 
    Set rsOrdDA = DEjxc.rsComOrdDA 
    Set cmOtHA = New ADODB.Command 
    cmOtHA.ActiveConnection = DEjxc.Conjxc 
    cmOtHA.CommandType = adCmdText 
    rsOrdDA.Filter = "order_id ='" & Me.txtother_id.Text & "'" 
    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) 
    rsOtHA.Close 
    rsOrdDA.Close 
    Set rsOtHA = Nothing 
    Set rsOrdDA = Nothing 
    Set cmOtHA = Nothing 
End Sub 
 
Private Sub OtHAAddNew() 
    Dim strSQL As String 
    With rsOtHA 
        .AddNew 
        rsOrdDA.Filter = "order_id ='" & Me.txtother_id.Text & "'" 
        Call IsEdit(True) 
        Me.txtother_date.Text = CStr(dteSysDate) 
        Me.txtother_maker.Text = strCurUser 
        Me.DCboOtherType.SetFocus 
    End With 
End Sub 
 
Private Sub IsEdit(blnIsEdit As Boolean) 
    Dim intNum As Integer 
    Me.txtother_car.Enabled = blnIsEdit 
    Me.txtother_date.Enabled = blnIsEdit 
    Me.txtother_demo.Enabled = blnIsEdit 
    Me.txtother_id.Enabled = blnIsEdit 
    Me.txtother_maker.Enabled = blnIsEdit 
    Me.DCboOtherType.Enabled = blnIsEdit 
    Me.DCboOtRid.Enabled = blnIsEdit 
    Me.DataGrid1.Enabled = Not blnIsEdit 
    If rsOrdDA.RecordCount <> 0 Then 
        Txtgrid2.Visible = blnIsEdit 
    Else 
        Txtgrid2.Visible = False 
    End If 
    For intNum = 0 To 3 
        Me.CmdAct(intNum).Enabled = blnIsEdit 
    Next 
    For intNum = 0 To 5 
        Me.CmdDep(intNum).Enabled = Not blnIsEdit 
    Next 
    If Me.txtother_id = "" Then 
        For intNum = 2 To 3 
            Me.CmdAct(intNum).Enabled = False 
        Next 
    End If 
    If rsOtHA.RecordCount = 0 Then 
        For intNum = 1 To 4 
            Me.CmdDep(intNum).Enabled = False 
        Next 
    End If 
End Sub 
 
Private Sub Txtgrid2_KeyDown(KeyCode As Integer, Shift As Integer) 
    Select Case KeyCode 
        Case vbKeyF2 
            If DataGrid2.Col = 1 Then 
                FrmFindPro.strFindPro = Txtgrid2.Text 
                FrmFindPro.Show vbModal 
                If FrmFindPro.strFindPro <> "" Then 
                    Txtgrid2.Text = FrmFindPro.strFindPro 
                    DataGrid2.Columns(1).Text = Txtgrid2.Text 
                End If 
            End If 
        Case vbKeyReturn 
            Call Column_value 
            Call Cal_Price 
            Call ColToRight 
            Call Txtgrid2_Leave 
        Case vbKeyLeft 
            Call Column_value 
            Call Cal_Price 
            Call ColToLeft 
            Call Txtgrid2_Leave 
        Case vbKeyRight 
            Call Column_value 
            Call Cal_Price 
            Call ColToRight 
            Call Txtgrid2_Leave 
        Case vbKeyUp 
            Call Column_value 
            Call Cal_Price 
            Call RowToUp 
            Call Txtgrid2_Leave 
        Case vbKeyDown 
            Call Column_value 
            Call Cal_Price 
            Call RowToDown 
            Call Txtgrid2_Leave 
    End Select 
End Sub 
 
Private Sub Txtgrid2_KeyPress(KeyAscii As Integer) 
    Dim strValid As String 
    If DataGrid2.Col = 2 Or DataGrid2.Col = 3 Then 
        strValid = "0123456789.-" 
        If KeyAscii > 26 Then 
            If InStr(strValid, Chr(KeyAscii)) = 0 Then 
                KeyAscii = 0 
            End If 
        End If 
    End If 
End Sub 
 
Private Sub txtother_car_KeyPress(KeyAscii As Integer) 
    If KeyAscii = 13 Then Me.txtother_demo.SetFocus 
End Sub 
 
Private Sub txtother_date_KeyPress(KeyAscii As Integer) 
    If KeyAscii = 13 Then Me.txtother_maker.SetFocus 
End Sub 
 
Private Sub txtother_id_KeyPress(KeyAscii As Integer) 
    If KeyAscii = 13 And txtother_id.Text <> "" Then 
        If Len(txtother_id.Text) = 7 Then 
            Select Case Me.DCboOtherType.SelectedItem 
                Case 1 
                    txtother_id.Text = "LT" & txtother_id.Text 
                Case 2 
                    txtother_id.Text = "DR" & txtother_id.Text 
            End Select 
        End If 
        CmdAct(2).Enabled = True 
        CmdAct(3).Enabled = True 
        Me.txtother_date.SetFocus 
    Else 
        CmdAct(2).Enabled = False 
        CmdAct(3).Enabled = False 
    End If 
End Sub 
 
Private Sub txtother_id_Validate(Cancel As Boolean) 
    If txtother_id.Text <> "" Then 
        If Len(txtother_id.Text) = 7 Then 
            Select Case Me.DCboOtherType.SelectedItem 
                Case 1 
                    txtother_id.Text = "LT" & txtother_id.Text 
                Case 2 
                    txtother_id.Text = "DR" & txtother_id.Text 
            End Select 
        End If 
        CmdAct(2).Enabled = True 
        CmdAct(3).Enabled = True 
    Else 
        CmdAct(2).Enabled = False 
        CmdAct(3).Enabled = False 
    End If 
End Sub 
 
Private Sub Txtgrid2_Leave() 
    Txtgrid2.Text = DataGrid2.Columns(DataGrid2.Col).Text 
    If DataGrid2.Columns(1).Text <> "" Then 
        LblStatus.Caption = Product_Status(DataGrid2.Columns(1).Text) 
    Else 
        LblStatus.Caption = "" 
    End If 
    Txtgrid2.SelStart = 0 
    Txtgrid2.SelLength = Len(Txtgrid2.Text) 
    Txtgrid2.Width = DataGrid2.Columns(DataGrid2.Col).Width 
    Txtgrid2.Left = DataGrid2.Left + DataGrid2.Columns(DataGrid2.Col).Left 
    Txtgrid2.Top = DataGrid2.Top + DataGrid2.Row * DataGrid2.RowHeight + 225 
    Txtgrid2.SetFocus 
End Sub 
 
Private Sub ColToRight() 
    If DataGrid2.Col < DataGrid2.Columns.Count - 2 Then 
        DataGrid2.Col = DataGrid2.Col + 1 
    Else 
        Call RowToDown 
        DataGrid2.Col = 1 
    End If 
End Sub 
 
Private Sub ColToLeft() 
    If DataGrid2.Col > 1 Then 
        DataGrid2.Col = DataGrid2.Col - 1 
    End If 
End Sub 
 
Private Sub RowToUp() 
    With rsOrdDA 
        If Not .BOF Then 
            .MovePrevious 
        End If 
        If .BOF Then .MoveNext 
    End With 
End Sub 
 
Private Sub RowToDown() 
    With rsOrdDA 
        If Not .EOF Then 
            .MoveNext 
        End If 
        If .EOF Then .MovePrevious 
    End With 
End Sub 
 
Private Sub Cal_Price() 
    With DataGrid2 
        If .Columns(2).Text <> "" And .Columns(3).Text <> "" Then 
            .Columns(4).Value = Round(CCur(.Columns(2).Value * .Columns(3).Value), 2) 
        End If 
    End With 
End Sub 
 
Private Function SaveValid() As Boolean 
    If (Left(Me.txtother_id.Text, 2) <> "LT" And Left(Me.txtother_id.Text, 2) <> "DR") Or Len(Me.txtother_id.Text) <> 9 Then 
        MsgBox "单据编号格式错误!", vbCritical, "错误" 
        txtother_id.SetFocus 
        SaveValid = False 
        Exit Function 
    End If 
    If Me.txtother_date.Text = "" Or (Not IsDate(Me.txtother_date.Text)) Then 
        MsgBox "日期格式错误!", vbCritical, "错误" 
        txtother_date.SetFocus 
        SaveValid = False 
        Exit Function 
    End If 
    If IsNull(Me.DCboOtherType.SelectedItem) Then 
        MsgBox "必须选择单据类型!", vbCritical, "错误" 
        Me.DCboOtherType.SetFocus 
        SaveValid = False 
        Exit Function 
    End If 
    If Me.txtother_maker = "" Then 
        MsgBox "制单人不能为空!", vbCritical, "错误" 
        txtother_maker.SetFocus 
        SaveValid = False 
        Exit Function 
    End If 
    If IsNull(Me.DCboOtRid.SelectedItem) Then 
        MsgBox "必须选择一个部门!", vbCritical, "错误" 
        Me.DCboOtRid.SetFocus 
        SaveValid = False 
        Exit Function 
    End If 
    If rsOrdDA.RecordCount = 0 Then 
        MsgBox "单据明细项不能为空!", vbCritical, "错误" 
        txtother_id.SetFocus 
        SaveValid = False 
        Exit Function 
    End If 
    SaveValid = True 
End Function 
 
Private Sub txtother_maker_KeyPress(KeyAscii As Integer) 
    If KeyAscii = 13 Then Me.DCboOtRid.SetFocus 
End Sub 
 
Private Sub Column_value() 
    With DataGrid2 
        If .Col = 2 Then 
            If Txtgrid2.Text <> "" Then .Columns(.Col).Text = CStr(Round(CSng(Txtgrid2.Text), 4)) 
        ElseIf .Col = 3 Then 
            If Txtgrid2.Text <> "" Then .Columns(.Col).Text = CStr(Round(CCur(Txtgrid2.Text), 2)) 
        Else 
            .Columns(.Col).Text = Txtgrid2.Text 
        End If 
    End With 
End Sub