www.pudn.com > jxc001.rar > FrmPsEdit.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 FrmPsEdit  
   Caption         =   "采购入库单编辑" 
   ClientHeight    =   6900 
   ClientLeft      =   60 
   ClientTop       =   345 
   ClientWidth     =   7725 
   Icon            =   "FrmPsEdit.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 VB.TextBox Txtgrid2  
         Height          =   270 
         Left            =   1200 
         TabIndex        =   26 
         Top             =   2100 
         Visible         =   0   'False 
         Width           =   1215 
      End 
      Begin VB.CommandButton CmdAct  
         Caption         =   "删除明细(&M)" 
         Enabled         =   0   'False 
         Height          =   315 
         Index           =   3 
         Left            =   6060 
         TabIndex        =   25 
         Top             =   3360 
         Width           =   1275 
      End 
      Begin VB.CommandButton CmdAct  
         Caption         =   "增加明细(&A)" 
         Enabled         =   0   'False 
         Height          =   315 
         Index           =   2 
         Left            =   4180 
         TabIndex        =   24 
         Top             =   3360 
         Width           =   1275 
      End 
      Begin MSDataGridLib.DataGrid DataGrid2  
         Bindings        =   "FrmPsEdit.frx":0442 
         Height          =   1575 
         Left            =   420 
         TabIndex        =   23 
         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 MSDataListLib.DataCombo DCboSup  
         Bindings        =   "FrmPsEdit.frx":0456 
         DataField       =   "ps_rid" 
         DataMember      =   "ComPsHA" 
         DataSource      =   "DEjxc" 
         Height          =   330 
         Left            =   5460 
         TabIndex        =   22 
         Top             =   285 
         Width           =   2055 
         _ExtentX        =   3625 
         _ExtentY        =   582 
         _Version        =   393216 
         Enabled         =   0   'False 
         MatchEntry      =   -1  'True 
         ListField       =   "supplier_name" 
         BoundColumn     =   "supplier_id" 
         Text            =   "" 
         Object.DataMember      =   "ComSupplier" 
      End 
      Begin VB.TextBox txtps_demo  
         DataField       =   "ps_demo" 
         DataMember      =   "ComPsHA" 
         DataSource      =   "DEjxc" 
         Enabled         =   0   'False 
         Height          =   330 
         Left            =   4560 
         TabIndex        =   21 
         Top             =   780 
         Width           =   2955 
      End 
      Begin VB.TextBox txtps_car  
         DataField       =   "ps_car" 
         DataMember      =   "ComPsHA" 
         DataSource      =   "DEjxc" 
         Enabled         =   0   'False 
         Height          =   330 
         Left            =   2760 
         TabIndex        =   19 
         Top             =   780 
         Width           =   1020 
      End 
      Begin VB.TextBox txtps_maker  
         DataField       =   "ps_maker" 
         DataMember      =   "ComPsHA" 
         DataSource      =   "DEjxc" 
         Enabled         =   0   'False 
         Height          =   330 
         Left            =   1200 
         TabIndex        =   17 
         Top             =   780 
         Width           =   765 
      End 
      Begin VB.TextBox txtps_date  
         DataField       =   "ps_date" 
         DataMember      =   "ComPsHA" 
         DataSource      =   "DEjxc" 
         Enabled         =   0   'False 
         Height          =   330 
         Left            =   3000 
         TabIndex        =   14 
         Top             =   285 
         Width           =   1080 
      End 
      Begin VB.TextBox txtps_id  
         DataField       =   "ps_id" 
         DataMember      =   "ComPsHA" 
         DataSource      =   "DEjxc" 
         Enabled         =   0   'False 
         Height          =   330 
         Left            =   1200 
         TabIndex        =   12 
         Top             =   285 
         Width           =   915 
      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 LblStatus  
         BorderStyle     =   1  'Fixed Single 
         ForeColor       =   &H00FF0000& 
         Height          =   315 
         Left            =   420 
         TabIndex        =   27 
         Top             =   2880 
         Width           =   6855 
      End 
      Begin VB.Label lblFieldLabel  
         Alignment       =   1  'Right Justify 
         AutoSize        =   -1  'True 
         Caption         =   "备注:" 
         Height          =   180 
         Index           =   7 
         Left            =   4080 
         TabIndex        =   20 
         Top             =   885 
         Width           =   450 
      End 
      Begin VB.Label lblFieldLabel  
         Alignment       =   1  'Right Justify 
         AutoSize        =   -1  'True 
         Caption         =   "车号:" 
         Height          =   180 
         Index           =   6 
         Left            =   2280 
         TabIndex        =   18 
         Top             =   870 
         Width           =   450 
      End 
      Begin VB.Label lblFieldLabel  
         Alignment       =   1  'Right Justify 
         AutoSize        =   -1  'True 
         Caption         =   "制单人:" 
         Height          =   180 
         Index           =   4 
         Left            =   540 
         TabIndex        =   16 
         Top             =   885 
         Width           =   630 
      End 
      Begin VB.Label lblFieldLabel  
         Alignment       =   1  'Right Justify 
         AutoSize        =   -1  'True 
         Caption         =   "对方单位:" 
         Height          =   180 
         Index           =   3 
         Left            =   4560 
         TabIndex        =   15 
         Top             =   330 
         Width           =   810 
      End 
      Begin VB.Label lblFieldLabel  
         Alignment       =   1  'Right Justify 
         AutoSize        =   -1  'True 
         Caption         =   "日期:" 
         Height          =   180 
         Index           =   1 
         Left            =   2520 
         TabIndex        =   13 
         Top             =   405 
         Width           =   450 
      End 
      Begin VB.Label lblFieldLabel  
         Alignment       =   1  'Right Justify 
         AutoSize        =   -1  'True 
         Caption         =   "单据编号:" 
         Height          =   180 
         Index           =   0 
         Left            =   360 
         TabIndex        =   11 
         Top             =   390 
         Width           =   810 
      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            =   6180 
         TabIndex        =   7 
         Top             =   2520 
         Width           =   1275 
      End 
      Begin VB.CommandButton CmdDep  
         Caption         =   "列表(&P)" 
         Height          =   315 
         Index           =   4 
         Left            =   6180 
         TabIndex        =   6 
         Top             =   2052 
         Width           =   1275 
      End 
      Begin VB.CommandButton CmdDep  
         Caption         =   "删除(&D)" 
         Height          =   315 
         Index           =   3 
         Left            =   6180 
         TabIndex        =   5 
         Top             =   1584 
         Width           =   1275 
      End 
      Begin VB.CommandButton CmdDep  
         Caption         =   "查询(&F)" 
         Height          =   315 
         Index           =   2 
         Left            =   6180 
         TabIndex        =   4 
         Top             =   1116 
         Width           =   1275 
      End 
      Begin VB.CommandButton CmdDep  
         Caption         =   "编辑(&E)" 
         Height          =   315 
         Index           =   1 
         Left            =   6180 
         TabIndex        =   3 
         Top             =   648 
         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        =   "FrmPsEdit.frx":0472 
         Height          =   2655 
         Left            =   60 
         TabIndex        =   1 
         Top             =   180 
         Width           =   5895 
         _ExtentX        =   10398 
         _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      =   "ComPsHA" 
         ColumnCount     =   6 
         BeginProperty Column00  
            DataField       =   "ps_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       =   "ps_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       =   "ps_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 Column03  
            DataField       =   "ps_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 Column04  
            DataField       =   "ps_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 Column05  
            DataField       =   "ps_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  
               ColumnAllowSizing=   0   'False 
               ColumnWidth     =   854.929 
            EndProperty 
            BeginProperty Column01  
               ColumnAllowSizing=   0   'False 
               ColumnWidth     =   900.284 
            EndProperty 
            BeginProperty Column02  
               ColumnAllowSizing=   0   'False 
               ColumnWidth     =   794.835 
            EndProperty 
            BeginProperty Column03  
               ColumnAllowSizing=   0   'False 
               ColumnWidth     =   599.811 
            EndProperty 
            BeginProperty Column04  
               ColumnAllowSizing=   0   'False 
               ColumnWidth     =   900.284 
            EndProperty 
            BeginProperty Column05  
               ColumnAllowSizing=   0   'False 
               ColumnWidth     =   1500.095 
            EndProperty 
         EndProperty 
      End 
   End 
End 
Attribute VB_Name = "FrmPsEdit" 
Attribute VB_GlobalNameSpace = False 
Attribute VB_Creatable = False 
Attribute VB_PredeclaredId = True 
Attribute VB_Exposed = False 
Option Explicit 
Private rsPsHA As ADODB.Recordset 
Private rsOrdDA As ADODB.Recordset 
Private rsRparame As ADODB.Recordset 
Private cmPsHA As ADODB.Command 
Private strMaxNum As String 
Private lngPsNum As Long 
 
Private Sub CmdAct_Click(Index As Integer) 
    Dim intRow As Integer 
    Dim blnIsTrue As Boolean 
    Dim strSQL As String 
    With rsPsHA 
        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.txtps_id.Text 
                            .MoveNext 
                        Wend 
                    End If 
                End With 
                rsOrdDA.Filter = "order_id='" & Me.txtps_id.Text & "'" 
                rsOrdDA.UpdateBatch 
                .Filter = "ps_id<>''" 
                .UpdateBatch 
                .MoveLast 
                Call IsEdit(False) 
                strSQL = "update r_parameter set psnumber=psnumber+1" 
                cmPsHA.CommandText = strSQL 
                cmPsHA.Execute 
            Case 1 
                rsOrdDA.CancelBatch 
                .Filter = "ps_id<>''" 
                If .RecordCount <> 0 Then 
                    .MoveFirst 
                End If 
                .CancelBatch 
                Call IsEdit(False) 
                rsOrdDA.Filter = "order_id='" & Me.txtps_id.Text & "'" 
            Case 2 
                rsOrdDA.AddNew "order_id", Me.txtps_id.Text 
                rsOrdDA.Filter = "order_id='" & Me.txtps_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 PsHAAddNew 
        Case 1 
            Call IsEdit(True) 
            Me.txtps_date.SetFocus 
            With rsOrdDA 
                If .RecordCount <> 0 Then 
                    .MoveFirst 
                    DataGrid2.Col = 1 
                    Call Txtgrid2_Leave 
                End If 
            End With 
        Case 2 
            FrmSql.intNumField = 6 
            FrmSql.Show vbModal 
            Select Case FrmSql.intNumField 
                Case -1 
                    CmdDep(0).Enabled = True 
                    CmdDep(3).Enabled = True 
                    rsPsHA.Filter = Me.DataGrid1.Columns.Item(0).DataField & _ 
                    "<>''" 
                    rsOrdDA.Filter = "order_id ='" & Me.txtps_id.Text & "'" 
                Case -2 
                Case Else 
                    CmdDep(0).Enabled = False 
                    CmdDep(3).Enabled = False 
                    rsPsHA.Filter = Me.DataGrid1.Columns.Item(FrmSql.intNumField).DataField & _ 
                    " like '*" & FrmSql.strSqlField & "*'" 
                    rsOrdDA.Filter = "order_id ='" & Me.txtps_id.Text & "'" 
            End Select 
        Case 3 
            intAnswer = MsgBox("确认删除当前记录吗?", vbYesNo + vbQuestion, "删除确认") 
            If intAnswer = vbYes Then 
                With rsPsHA 
                    strSQL = "delete from order_detail_a where order_id='" & Me.txtps_id.Text & "'" 
                    cmPsHA.CommandText = strSQL 
                    cmPsHA.Execute 
                    .Delete 
                    .UpdateBatch 
                    If .RecordCount <> 0 Then 
                        .MoveFirst 
                    End If 
                    rsOrdDA.Filter = "order_id ='" & Me.txtps_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.txtps_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 DCboSup_KeyPress(KeyAscii As Integer) 
    If KeyAscii = 13 Then Me.txtps_maker.SetFocus 
End Sub 
 
Private Sub Form_Load() 
    intNumWindows = OpenWindow(intNumWindows) 
    Me.Height = 7305 
    Me.Width = 7845 
    Call SetFormStu(Me, frmMain) 
    Set rsPsHA = DEjxc.rsComPsHA 
    Set rsOrdDA = DEjxc.rsComOrdDA 
    Set rsRparame = New ADODB.Recordset 
    Set cmPsHA = New ADODB.Command 
    cmPsHA.ActiveConnection = DEjxc.Conjxc 
    cmPsHA.CommandType = adCmdText 
    rsOrdDA.Filter = "order_id ='" & Me.txtps_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) 
    rsPsHA.Close 
    rsOrdDA.Close 
    Set rsPsHA = Nothing 
    Set rsOrdDA = Nothing 
    Set rsRparame = Nothing 
    Set cmPsHA = Nothing 
End Sub 
 
Private Sub PsHAAddNew() 
    Dim strSQL As String 
    With rsPsHA 
        .AddNew 
        strSQL = "select psnumber from r_parameter" 
        rsRparame.Open strSQL, DEjxc.Conjxc, adOpenDynamic, adLockOptimistic 
        With rsRparame 
            .MoveFirst 
            lngPsNum = CLng(!psnumber) + 1 
        End With 
        Me.txtps_id.Text = "CR" & Format(lngPsNum, "0######") 
        rsRparame.Close 
        rsOrdDA.Filter = "order_id ='" & Me.txtps_id.Text & "'" 
        Call IsEdit(True) 
        Me.txtps_date.Text = CStr(dteSysDate) 
        Me.txtps_maker.Text = strCurUser 
        Me.txtps_date.SetFocus 
    End With 
End Sub 
 
Private Sub IsEdit(blnIsEdit As Boolean) 
    Dim intNum As Integer 
    Me.txtps_car.Enabled = blnIsEdit 
    Me.txtps_date.Enabled = blnIsEdit 
    Me.txtps_demo.Enabled = blnIsEdit 
    'Me.txtps_id.Enabled = blnIsEdit 
    Me.txtps_maker.Enabled = blnIsEdit 
    Me.DCboSup.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.txtps_id = "" Then 
        For intNum = 2 To 3 
            Me.CmdAct(intNum).Enabled = False 
        Next 
    End If 
    If rsPsHA.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 txtps_car_KeyPress(KeyAscii As Integer) 
    If KeyAscii = 13 Then Me.txtps_demo.SetFocus 
End Sub 
 
Private Sub txtps_date_KeyPress(KeyAscii As Integer) 
    If KeyAscii = 13 Then Me.DCboSup.SetFocus 
End Sub 
 
Private Sub txtps_id_KeyPress(KeyAscii As Integer) 
    If KeyAscii = 13 And txtps_id.Text <> "" Then 
        If Len(txtps_id.Text) = 7 Then 
            txtps_id.Text = "CR" & txtps_id.Text 
        End If 
        CmdAct(2).Enabled = True 
        CmdAct(3).Enabled = True 
        Me.txtps_date.SetFocus 
    Else 
        CmdAct(2).Enabled = False 
        CmdAct(3).Enabled = False 
    End If 
End Sub 
 
Private Sub txtps_id_Validate(Cancel As Boolean) 
    If txtps_id.Text <> "" Then 
        If Len(txtps_id.Text) = 7 Then 
            txtps_id.Text = "CR" & txtps_id.Text 
        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 txtps_maker_KeyPress(KeyAscii As Integer) 
    If KeyAscii = 13 Then Me.txtps_car.SetFocus 
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.txtps_id.Text, 2) <> "CR" Or Len(Me.txtps_id.Text) <> 9 Then 
        MsgBox "单据编号格式错误!", vbCritical, "错误" 
        txtps_id.SetFocus 
        SaveValid = False 
        Exit Function 
    End If 
    If Me.txtps_date.Text = "" Or (Not IsDate(Me.txtps_date.Text)) Then 
        MsgBox "日期格式错误!", vbCritical, "错误" 
        txtps_date.SetFocus 
        SaveValid = False 
        Exit Function 
    End If 
    If IsNull(Me.DCboSup.SelectedItem) Then 
        MsgBox "必须选择一个供应商!", vbCritical, "错误" 
        Me.DCboSup.SetFocus 
        SaveValid = False 
        Exit Function 
    End If 
    If Me.txtps_maker = "" Then 
        MsgBox "制单人不能为空!", vbCritical, "错误" 
        txtps_maker.SetFocus 
        SaveValid = False 
        Exit Function 
    End If 
    If rsOrdDA.RecordCount = 0 Then 
        MsgBox "单据明细项不能为空!", vbCritical, "错误" 
        txtps_date.SetFocus 
        SaveValid = False 
        Exit Function 
    End If 
    SaveValid = True 
End Function 
 
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