📄 frmwater.frm
字号:
VERSION 5.00
Begin VB.Form frmWater
Caption = "饮水机设置"
ClientHeight = 5130
ClientLeft = 60
ClientTop = 345
ClientWidth = 5865
LinkTopic = "Form1"
ScaleHeight = 5130
ScaleWidth = 5865
StartUpPosition = 3 '窗口缺省
Begin VB.Frame Frame1
Caption = "饮水机设置"
Height = 3855
Left = 240
TabIndex = 1
Top = 240
Width = 5415
Begin VB.TextBox Text
Height = 270
Index = 0
Left = 1680
TabIndex = 3
Top = 480
Width = 1815
End
Begin VB.TextBox Text
Height = 270
Index = 1
Left = 1680
TabIndex = 2
Top = 840
Width = 1815
End
Begin VB.TextBox Text
Height = 270
Index = 2
Left = 1680
TabIndex = 4
Top = 1200
Width = 1815
End
Begin VB.ComboBox Combo1
Height = 300
Left = 1680
TabIndex = 6
Text = "Combo1"
Top = 1560
Width = 1935
End
Begin VB.TextBox Text
Height = 1335
Index = 3
Left = 360
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 8
Top = 2280
Width = 4815
End
Begin VB.Label Label1
Caption = "饮水机编号:"
Height = 255
Index = 0
Left = 360
TabIndex = 13
Top = 480
Width = 1095
End
Begin VB.Label Label1
Caption = "饮水机型号:"
Height = 255
Index = 1
Left = 360
TabIndex = 11
Top = 840
Width = 1215
End
Begin VB.Label Label1
Caption = "零售价:"
Height = 255
Index = 2
Left = 360
TabIndex = 9
Top = 1200
Width = 855
End
Begin VB.Label Label1
Caption = "供应商名称:"
Height = 255
Index = 4
Left = 360
TabIndex = 7
Top = 1560
Width = 1095
End
Begin VB.Label Label1
Caption = "备注:"
Height = 255
Index = 5
Left = 360
TabIndex = 5
Top = 1920
Width = 855
End
End
Begin VB.Frame Frame2
Height = 735
Left = 240
TabIndex = 0
Top = 4200
Width = 5415
Begin VB.CommandButton Command3
Caption = "返回"
Height = 375
Left = 3480
TabIndex = 14
Top = 240
Width = 1095
End
Begin VB.CommandButton Command2
Caption = "保存"
Height = 375
Left = 2040
TabIndex = 12
Top = 240
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "重设"
Height = 375
Left = 600
TabIndex = 10
Top = 240
Width = 1095
End
End
End
Attribute VB_Name = "frmWater"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'****************************************************************************
'人人为我,我为人人
'枕善居收藏整理
'发布日期:2006/12/06
'描 述: 纯净水进销存管理系统 Ver 2.0
'网 站:http://www.Mndsoft.com/ (VB6源码博客)
'网 站:http://www.VbDnet.com/ (VB.NET源码博客,主要基于.NET2005)
'e-mail :Mndsoft@163.com
'e-mail :Mndsoft@126.com
'OICQ :88382850
' 如果您有新的好的代码别忘记给枕善居哦!
'****************************************************************************
Private Sub Command1_Click()
Dim t As Integer
For t = 0 To 3
Text(t) = ""
Next
End Sub
Private Sub Command2_Click()
Dim t As Integer
'//输入校验
For t = 0 To 2
If Text(t) = "" Or Combo1.Text = "" Then
MsgBox "请将信息输入完整,前三项为必填选项", vbExclamation, "输入提示"
Text(t).SetFocus
Exit Sub
End If
Next
Dim sqlWM As String
Dim rsWM As ADODB.Recordset
If wmEdit <> 1 Then '如果相等,则表示是添加新记录,否则为修改记录
sqlWATER = "select * from 饮水机 where 饮水机编号='" & Val(Trim(Text(0).Text)) & "'"
Set rsWATER = ExeSQL(sqlWATER)
If Not rsWATER.EOF Then
MsgBox "已经存在编号为" & Trim(Text(0).Text) & "的记录,请重新输入", vbYesNo, "系统提示"
rsWATER.Close
Set rsWATER = Nothing
Exit Sub
End If
If Text(3).Text <> "" Then '判断备注是否为空,写出不同的插入语句
sqlWM = "insert into 饮水机(饮水机编号,饮水机型号,零售价,供应商名称,备注) values('" & Trim(Text(0).Text) & "','" & Trim(Text(1).Text) & "',"
sqlWM = sqlWM & Val(Trim(Text(2).Text)) & ","
sqlWM = sqlWM & "'" + Trim(Combo1.Text) & "','" & Trim(Text(3).Text) & "')"
Else
sqlWM = "insert into 饮水机(饮水机编号,饮水机型号,零售价,供应商名称) values('" & Trim(Text(0).Text) & "','" & Trim(Text(1).Text) & "',"
sqlWM = sqlWM & Val(Trim(Text(2).Text)) & ","
sqlWM = sqlWM & "'" + Trim(Combo1.Text) & "')"
End If
ExeSQL (sqlWM)
MsgBox "饮水机添加成功,请返回", vbInformation, "系统提示"
Call Command1_Click
frmWaterInfo.showdata
Else
'先删除掉旧纪录,再添加新纪录,来达到更新记录的目的
sqlWM = "delete from 饮水机 where 饮水机编号='" & Trim(frmWaterInfo.msgList.TextMatrix(frmWaterInfo.msgList.Row, 1)) & "'"
ExeSQL (sqlWM)
sqlWATER = "select * from 饮水机 where 饮水机编号='" & Val(Trim(Text(0).Text)) & "'"
Set rsWATER = ExeSQL(sqlWATER)
If Not rsWATER.EOF Then
MsgBox "已经存在编号为" & Trim(Text(0).Text) & "的记录,请重新输入", vbYesNo, "系统提示"
rsWATER.Close
Set rsWATER = Nothing
Exit Sub
End If
sqlWM = "insert into 饮水机 values('" & Trim(Text(0).Text) & "','" & Trim(Text(1).Text) & "',"
sqlWM = sqlWM & Val(Trim(Text(2).Text)) & ","
sqlWM = sqlWM & "'" + Trim(Combo1.Text) & "'"
If Trim(Text(3).Text) <> "" Then
sqlWM = sqlWM & ",'" & Trim(Text(3).Text) & "')"
Else
sqlWM = sqlWM & ")"
End If
ExeSQL (sqlWM)
MsgBox "记录修改成功,请返回", vbInformation, "系统提示"
Call Command1_Click
frmWaterInfo.showdata
wmEdit = 0
Unload Me
End If
End Sub
Private Sub Command3_Click()
Unload Me
End Sub
Private Sub Form_Load()
Call loadgongyingshang
End Sub
Private Sub loadgongyingshang() '加载供应商列表
Dim rsgys As ADODB.Recordset
Dim sql As String
sql = "select 供应商编号,供应商名称 from 供应商表"
Set rsgys = ExeSQL(sql)
If Not rsgys.EOF Then
Dim i As Integer
For i = 1 To rsgys.RecordCount
Combo1.AddItem (rsgys.Fields("供应商名称"))
rsgys.MoveNext
Next
Combo1.Text = Combo1.List(0)
Else
Combo1.Text = "Null"
End If
End Sub
Public Sub showdata(txtsql As String)
On Error GoTo errhandle
Dim rsshow As ADODB.Recordset
Dim i As Integer
If txtsql = "" Then
txtsql = "select * from 饮水机"
End If
Set rsshow = ExeSQL(txtsql)
For i = 0 To 2
Text(i) = rsshow.Fields(i)
Next
Combo1.Text = rsshow.Fields(3)
Text(3).Text = rsshow.Fields(4)
rsshow.Close
Set rsshow = Nothing
Exit Sub
errhandle:
If Err.Number = 91 Or Err.Number = -2147217900 Then
Resume Next
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
If wmEdit = 1 Then
wmEdit = 0
End If
Set frmWater = Nothing
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -