frmpinfo.frm
来自「这个是VB环境开发的,我也是转载的把原来的Access数据库改成了SQl Ser」· FRM 代码 · 共 638 行 · 第 1/2 页
FRM
638 行
Top = 615
Width = 720
End
Begin VB.Label Lbl4
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "产品类型:"
Height = 180
Index = 1
Left = 2760
TabIndex = 4
Top = 240
Width = 900
End
End
Begin MSComctlLib.ImageList ImageList1
Left = 7200
Top = 0
_ExtentX = 1005
_ExtentY = 1005
BackColor = -2147483643
ImageWidth = 16
ImageHeight = 16
MaskColor = 12632256
_Version = 393216
BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
NumListImages = 7
BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmPinfo.frx":3F60
Key = ""
EndProperty
BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmPinfo.frx":45DC
Key = ""
EndProperty
BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmPinfo.frx":4C58
Key = ""
EndProperty
BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmPinfo.frx":4D6C
Key = ""
EndProperty
BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmPinfo.frx":53E8
Key = ""
EndProperty
BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmPinfo.frx":5A64
Key = ""
EndProperty
BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmPinfo.frx":5CF8
Key = ""
EndProperty
EndProperty
End
Begin MSComctlLib.Toolbar Toolbar1
Align = 1 'Align Top
Height = 555
Left = 0
TabIndex = 0
Top = 0
Width = 8085
_ExtentX = 14261
_ExtentY = 979
ButtonWidth = 979
ButtonHeight = 926
Appearance = 1
Style = 1
ImageList = "ImageList1"
_Version = 393216
BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628}
NumButtons = 8
BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "新 增"
Key = "new"
ImageIndex = 1
EndProperty
BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "保 存"
Key = "save"
ImageIndex = 2
EndProperty
BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "删 除"
Key = "dele"
ImageIndex = 3
EndProperty
BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "查 找"
Key = "find"
ImageIndex = 4
EndProperty
BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628}
Object.Visible = 0 'False
Style = 3
EndProperty
BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "修 改"
Key = "print"
ImageIndex = 7
EndProperty
BeginProperty Button7 {66833FEA-8583-11D1-B16A-00C0F0283628}
Style = 3
EndProperty
BeginProperty Button8 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "退 出"
Key = "exit "
ImageIndex = 6
EndProperty
EndProperty
End
End
Attribute VB_Name = "frmPinfo"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim RsP As New Recordset
Public InsertType As String
Private Flg As Boolean
Private Sub CmdInsert_Click()
On Error GoTo l
If frmPinfo.InsertType = "FRMIOorder" Then
frmioorder.lblprod = txtid
frmioorder.txtProd = txtname
frmioorder.txttype = txttype
Unload Me
frmioorder.txtPrice.SetFocus
Else
If frmIFind.cmdE1 Then
frmIFind.txtele = txtname
frmIFind.txtele1 = txtname
Unload Me
Else
frmIFind.txtele1 = txtname
Unload Me
End If
End If
Exit Sub
l: MsgBox err.Description
End Sub
Private Sub dtgrd_Click()
CmdInsert.Visible = True
CmdInsert.Enabled = True
On Error GoTo l
txtid = dtgrd.Columns(0).Text
Toolbar1.Buttons(6).Enabled = True
Exit Sub
l: Exit Sub
End Sub
Private Sub dtgrd_DblClick()
CmdInsert_Click
End Sub
Private Sub dtgrd_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
If Not (RsP.BOF Or RsP.EOF) Then
dtgrd_Click
End If
End Sub
Private Sub Form_Load()
RsP.Open "select * from prostock", cn, adOpenKeyset, adLockBatchOptimistic
RsP.Filter = ""
Set dtgrd.DataSource = RsP
Toolbar1.Buttons(2).Enabled = False
Toolbar1.Buttons(6).Enabled = False
statusP.Panels(1).Text = "产品总数:" & RsP.RecordCount & "个"
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set RsP = Nothing
End Sub
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
On Error GoTo gl
Dim cmd As New ADODB.Command
Dim Re As String
Dim Idadd As Integer
Select Case Trim(Button.Key)
Case "new"
frmp.Enabled = True
txtid = ""
txtname = ""
txtgg = ""
txtunit = ""
txttype = ""
txtstock = ""
txtname.Enabled = True
txtname.SetFocus
Toolbar1.Buttons(3).Enabled = False
Toolbar1.Buttons(2).Enabled = True
'Toolbar1.Buttons(6).Enabled = False
Toolbar1.Buttons(1).Enabled = False
Case "save"
If Toolbar1.Buttons(1).Enabled = False Then
If Len(txtname.Text) < 0 Or Trim(txttype) = "" Then
MsgBox " 数据输入不完整! ", , ginfo
Exit Sub
End If
'rsp.Find "pname= '" & Trim(txtname) & "'"
RsP.Find "ptype='" & Trim(txttype) & "'"
If Not (RsP.BOF Or RsP.EOF) Then
MsgBox " 该产品已经存在! ", , ginfo
txtname.SetFocus
Exit Sub
End If
Idadd = RsP.RecordCount
RsP.AddNew
RsP!ID = Idadd + 1
RsP!pname = txtname
RsP!pstardard = txtgg & ""
RsP!Punit = txtunit
RsP!ptype = txttype & ""
RsP!pstock = 0
RsP!Pcom = "Cp" & RsP.RecordCount + 1
RsP.UpdateBatch adAffectCurrent
'rsP.Requery
frmp.Enabled = False
Toolbar1.Buttons(3).Enabled = True
Toolbar1.Buttons(6).Enabled = True
Toolbar1.Buttons(2).Enabled = False
Toolbar1.Buttons(1).Enabled = True
Else
If txtname <> "" Then RsP.Filter = "pname= '" & Trim(txtname) & "'and id<> " & txtid & ""
If Not (RsP.BOF Or RsP.EOF) Then
MsgBox " 该产品已经存在! ", , ginfo
txtname.SetFocus
Exit Sub
End If
RsP.Close
Set RsP = Nothing
Form_Load
RsP.Find "id=" & txtid
RsP!pname = txtname
RsP!pstardard = txtgg & ""
RsP!Punit = txtunit
RsP!ptype = txttype & ""
RsP!pstock = txtstock
RsP.UpdateBatch adAffectCurrent
RsP.Requery
RsP.Find "pname='" & txtname & "'"
Toolbar1.Buttons(3).Enabled = True
'Toolbar1.Buttons(1).Enabled = True
Toolbar1.Buttons(6).Enabled = True
Toolbar1.Buttons(2).Enabled = False
frmp.Enabled = False
End If
Case "dele"
On Error GoTo l
Re = MsgBox(" 你确定要删除数据吗?", vbYesNo + vbQuestion, ginfo)
If Re = vbYes Then
If txtid = "" Then txtid = dtgrd.Columns(0).Text
RsP.Find "id=" & txtid
cmd.ActiveConnection = cn
cmd.CommandText = "delete * from prostock where id=" & txtid
cmd.Execute
RsP.MoveNext
If Not (RsP.EOF Or RsP.BOF) Then
Do While Not RsP.EOF
If Val(txtid) <= RsP!ID Then
RsP!ID = RsP!ID - 1
RsP.UpdateBatch adAffectCurrent
RsP.MoveNext
Else
Exit Do
End If
Loop
End If
RsP.Requery
Else
Exit Sub
End If
Exit Sub
l: MsgBox err.Description
Case "find"
Re = InputBox("请输入产品名称:", "查找信息", Default, 2500, 2500)
If Re <> "" Then
RsP.Filter = "pname like '%" & Trim(Re) & "%'"
If RsP.BOF Or RsP.EOF Then
MsgBox " 对不起,没找到该记录!", , ginfo
Set RsP = Nothing
Form_Load
Exit Sub
End If
End If
Case "print"
frmp.Enabled = True
txtgg.SetFocus
Toolbar1.Buttons(6).Enabled = False
Toolbar1.Buttons(2).Enabled = True
Case "exit"
Unload Me
End Select
Exit Sub
gl: MsgBox err.Description
End Sub
Private Sub txtid_Change()
If txtid.Text <> "" Then
RsP.Find "id=" & txtid
If Not RsP.BOF Or Not RsP.EOF Then
If Not IsNull(RsP!pname) Then txtname = RsP!pname
txtgg = RsP!pstardard & ""
txtunit = RsP!Punit & ""
txttype = RsP!ptype & ""
txtstock = RsP!pstock & ""
End If
End If
End Sub
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?