addware.frm

来自「一个企业生产管理系统」· FRM 代码 · 共 504 行 · 第 1/2 页

FRM
504
字号
      Index           =   1
      Left            =   120
      TabIndex        =   15
      Top             =   1335
      Width           =   1815
   End
   Begin VB.Label lblLabels 
      Caption         =   "数   量"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   9.75
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Index           =   2
      Left            =   840
      TabIndex        =   14
      Top             =   1800
      Width           =   855
   End
   Begin VB.Label lblLabels 
      Caption         =   "war_ware_id:"
      Height          =   255
      Index           =   3
      Left            =   120
      TabIndex        =   13
      Top             =   2220
      Width           =   1815
   End
   Begin VB.Label lblLabels 
      Caption         =   "所属类别"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   9.75
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Index           =   4
      Left            =   840
      TabIndex        =   12
      Top             =   2880
      Width           =   855
   End
End
Attribute VB_Name = "addware"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit


Private Sub Form_Activate()

txtFields(0).SetFocus
txtFields(0).Text = strright
Text1.Text = strwarename

End Sub

Private Sub Form_GotFocus()
txtFields(0).Text = strright
End Sub

Private Sub Form_Load()
Select Case iflag
Case 1
cmdAdd_Click
cmdAdd.Visible = False
cmdDelete.Visible = False
cmdRefresh.Visible = False
cmdClose.Visible = False
Case 0

cmdAdd_Click
cmdAdd.Visible = False
cmdDelete.Visible = False
cmdRefresh.Visible = False
cmdClose.Visible = False
'cmdEdit_Click
Case 2
datPrimaryRS.RecordSource = "select * from ware_product where ware_layer_id = '" & strleft & "'"
datPrimaryRS.Refresh
'cmdDelete_Click
End Select

'iflag = 0 '复原

End Sub

Private Sub Form_Unload(Cancel As Integer)
  Screen.MousePointer = vbDefault
End Sub

Private Sub datPrimaryRS_Error(ByVal ErrorNumber As Long, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, fCancelDisplay As Boolean)
  '错误处理程序代码置于此处
  '想要忽略错误,注释掉下一行
  '想要捕获它们,在此添加代码以处理它们
  MsgBox "Data error event hit err:" & Description
End Sub

Private Sub datPrimaryRS_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
  '为这个 recordset 显示当前记录位置
  datPrimaryRS.Caption = "Record: " & CStr(datPrimaryRS.Recordset.AbsolutePosition)
End Sub

Private Sub datPrimaryRS_WillChangeRecord(ByVal adReason As ADODB.EventReasonEnum, ByVal cRecords As Long, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
  '验证代码置于此处
  '下列动作发生时该事件被调用
  Dim bCancel As Boolean

  Select Case adReason
  Case adRsnAddNew
  Case adRsnClose
  Case adRsnDelete
  Case adRsnFirstChange
  Case adRsnMove
  Case adRsnRequery
  Case adRsnResynch
  Case adRsnUndoAddNew
  Case adRsnUndoDelete
  Case adRsnUndoUpdate
  Case adRsnUpdate
  End Select

  If bCancel Then adStatus = adStatusCancel
End Sub

Private Sub cmdAdd_Click()
  On Error GoTo AddErr
  datPrimaryRS.Recordset.AddNew
  Select Case iflag
  Case 1
  txtFields(3).Text = strleft
  Case 0
 
  txtFields(3).Text = strleft
  End Select
  Exit Sub
AddErr:
  MsgBox Err.Description
End Sub

Private Sub cmdDelete_Click()
  On Error GoTo DeleteErr
  With datPrimaryRS.Recordset
    .Delete
    .MoveNext
    If .EOF Then .MoveLast
  End With
  Exit Sub
DeleteErr:
  MsgBox Err.Description
End Sub

Private Sub cmdRefresh_Click()
  '只有多用户应用程序需要
  On Error GoTo RefreshErr
  datPrimaryRS.Refresh
  Exit Sub
RefreshErr:
  MsgBox Err.Description
End Sub

Private Sub cmdUpdate_Click()
Dim strwareinfo As String
Dim rsa As New ADODB.Recordset
Dim j As Integer
Dim stemp As String
Dim DB1 As New ADODB.Connection
iseek = 0
  On Error GoTo UpdateErr
  If compare_wareid(strleft, txtFields(0)) = False Then
  If MsgBox("零件输入不合法,请重新输入", vbOKOnly, "输入错误") = vbOK Then Exit Sub
  End If
  If txtFields(2).Text = "" Or DataCombo1.Text = "" Then
  If MsgBox("请输入数量或类别") = vbOK Then Exit Sub
  End If
'擦擦擦
'cn.Execute ""
strwareinfo = "where war_ware_id like '%" & txtFields(0).Text & "%'"
'strwareinfo = "where ware_layer_id not like '%' "
'    With DB1
'        .ConnectionString = "Provider=MSDASQL.1;Persist Security Info=False;Data Source=warehouse;"
'        .Open
'    End With
'DB1.Execute "if exists (select * from sysobjects where id = object_id(N'[dbo].[test0]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [dbo].[test0]"
'DB1.Execute "CREATE TABLE [dbo].[test0] (   [ware_layer_id] [VARchar] (50) NOT NULL ,[warename] [VARchar](25) NULL , [quantity] [numeric] (7,2) NULL)"
'DB1.Execute "INSERT INTO TEST0  ( TEST0.WARE_LAYER_ID ) VALUES  ( txtFields(1).Text ) "

  seek_item strwareinfo, 0, 0
strwareinfo = "select * from test0"
For j = 1 To i - 1
strwareinfo = strwareinfo & "union select * from test" & CStr(j)
Next
rsa.Open strwareinfo, cn, adOpenStatic, adLockBatchOptimistic
With rsa
'''''''''If .RecordCount < 1 Then Exit Sub   原来在这里出错
If .RecordCount < 1 Then GoTo ExitSub
.MoveFirst
Do While Not .EOF
stemp = .Fields("ware_id").Value
If compare_wareid(txtFields(1).Text, stemp) = False Then
    If MsgBox("逻辑错误", vbOKOnly, "错误提示") = vbOK Then Exit Sub
End If
.MoveNext
Loop

End With

auto_expant

'判断是否零件重复,参见模块seek_item
'擦擦擦
ExitSub:
  datPrimaryRS.Recordset.UpdateBatch adAffectCurrent
  If MsgBox("是否还要添加", vbYesNo, "提示信息") = vbYes Then
  cmdAdd_Click
  Exit Sub
  Else
  Unload Me
  Exit Sub
   End If
UpdateErr:
'If MsgBox("请输X入数量") = vbOK Then Exit Sub
 MsgBox Err.Description
End Sub

Private Sub cmdClose_Click()
  Unload Me
End Sub

Private Sub Picture1_Click()
wareinfo1.Show
End Sub

Private Sub Text1_Change()
'DataCombo2.RowSource = "SELECT * FROM wareinfo WHERE ware_id LIKE 'c%' or warename like '%' & text1.text & '%'"
End Sub

Private Sub txtFields_Change(Index As Integer)
txtFields(1).Text = Trim(strleft) & "-" & txtFields(0).Text
End Sub

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?