主题:求救,过程声明与同名事件或过程的描述不匹配
Dim ltmW As ListItem
Dim Sql As String
Dim msg As String
Dim RS As ADODB.Recordset
Private Sub cmdAdd_Click()
'添加
Dim i As Integer
If Trim(Me.txtNo.Text) <> "" And Trim(Me.txtSum.Text) <> "" Then
Sql = "select 商品编号,销售价 from 商品库存表 where 商品编号= " & Trim(Me.txtNo.Text)
Set RS = SelectSQL(Sql, msg)
If RS.EOF Then
MsgBox "库中无此商品!"
Else
For i = 1 To Me.ListView1.ListItems.Count
If Me.ListView1.ListItems(i).Text = Trim(Me.txtNo.Text) Then
MsgBox "列表中已有!"
Exit Sub
End If
Next i
Set ltmW = Me.ListView1.ListItems.Add
ltmW.Text = Trim(Me.txtNo.Text)
ltmW.ListSubItems.Add , , RS.Fields(0)
ltmW.ListSubItems.Add , , RS.Fields(3)
ltmW.ListSubItems.Add , , Trim(Me.txtSum.Text)
'ltmW.ListSubItems.Add , , RS.Fields(2)
Me.txtAllValue.Text = Val(Me.txtAllValue.Text) + Val(Trim(Me.txtSum.Text)) * RS.Fields(3)
Me.txtAllValue.Text = Format(Me.txtAllValue.Text, "#.##")
End If
RS.Close
Else
MsgBox "主键不能为空!"
End If
End Sub
Private Sub cmdAll_Click()
'结账数据入库
Dim i As Integer
For i = 1 To Me.ListView1.ListItems.Count
Sql = "insert into 销售单表 values(" & Me.ListView1.ListItems(i).Text
Sql = Sql & ",'" & Date
Sql = Sql & "'," & Me.ListView1.ListItems(i).ListSubItems(3).Text
Sql = Sql & ",'" & Time
Sql = Sql & "')"
' dbOperateW Sql
BatchSelectSQL Sql
Next i
Me.txtR.Text = Str((Val(Trim(Me.txtGive.Text)) - Val(Trim(Me.txtAllValue.Text))))
Me.txtR.Text = Format(Me.txtR.Text, "#.##")
MsgBox "操作成功!总金额为" & Trim(Me.txtAllValue.Text) & "元,应找金额为" & Me.txtR.Text & "元"
Me.txtNo.Text = ""
Me.txtSum.Text = ""
Me.txtValue.Text = ""
Me.txtAllValue.Text = ""
End Sub
Private Sub cmdDel_Click()
'删除
Dim i As Integer, bln As Boolean
If Trim(Me.txtNo.Text) <> "" Then
For i = 1 To Me.ListView1.ListItems.Count
If Me.ListView1.ListItems(i).Text = Trim(Me.txtNo.Text) Then
bln = True
Exit For
End If
Next i
If bln = True Then
Me.txtAllValue.Text = Val(Me.txtAllValue.Text) - Val(Me.ListView1.ListItems(i).ListSubItems(2)) * _
Val(Me.ListView1.ListItems(i).ListSubItems(3))
Me.txtAllValue.Text = Format(Me.txtAllValue.Text, "#.##")
Me.ListView1.ListItems.Remove (i)
Me.txtNo.Text = ""
Me.txtSum.Text = ""
Me.txtValue.Text = ""
Else
MsgBox "列表中没有!"
End If
Else
MsgBox "主键不能为空!"
End If
End Sub
Private Sub cmdExit_Click()
'退出操作
超市销售管理系统.Show
Unload Me
End Sub
Private Sub Form_Unload(Cancel As Integer)
'退出操作
超市销售管理系统.Enabled = True
Unload Me
End Sub
Private Sub cmdModify_Click()
'修改
Dim i As Integer, bln As Boolean
If Trim(Me.txtNo.Text) <> "" Then
For i = 1 To Me.ListView1.ListItems.Count
If Me.ListView1.ListItems(i).Text = Trim(Me.txtNo.Text) Then
bln = True
Exit For
End If
Next i
If bln = True Then
Me.txtAllValue.Text = Val(Me.txtAllValue.Text) + Val(Me.ListView1.ListItems(i).ListSubItems(2)) * _
(Val(Trim(txtSum.Text)) - Val(Me.ListView1.ListItems(i).ListSubItems(3)))
Me.txtAllValue.Text = Format(Me.txtAllValue.Text, "#.##")
Me.ListView1.ListItems(i).ListSubItems(3).Text = Trim(txtSum.Text)
Else
MsgBox "列表中没有!"
End If
Else
MsgBox "主键不能为空!"
End If
End Sub
Private Sub Command1_Click()
Me.ListView1.ListItems.Clear
End Sub
'Private Sub Form_Resize()
'控件大小的动态调整
'Dim i As Integer
'Me.ListView1.Width = Me.ScaleWidth
'For i = 1 To 5
' Me.ListView1.ColumnHeaders(i).Width = Me.ListView1.Width / 5
'Next i
'Me.ListView1.Top = 0
'Me.ListView1.Height = Me.ScaleHeight - Me.Picture1.Height
'Me.Picture1.Top = Me.ScaleHeight - Me.Picture1.Height
'Me.Picture1.Width = Me.ScaleWidth
'End Sub
Private Sub ListView1_ItemClick(ByVal Item As MSComctlLib.ListItem)
Me.txtNo.Text = Item.Text
Me.txtValue.Text = Item.ListSubItems(2).Text
Me.txtSum.Text = Item.ListSubItems(3).Text
End Sub
Private Sub txtGive_KeyPress(KeyAscii As Integer)
'实付金额
If Not IsNumeric(Trim(Me.txtGive.Text)) And Trim(Me.txtGive.Text) <> "" Then
MsgBox "请输入数字!"
End If
End Sub
Private Sub txtNo_KeyPress(KeyAscii As Integer)
'商品编号
If Not IsNumeric(Trim(Me.txtNo.Text)) And Trim(Me.txtNo.Text) <> "" Then
MsgBox "请输入数字!"
End If
End Sub
Private Sub txtR_KeyPress(KeyAscii As Integer)
'应找金额
If Not IsNumeric(Trim(Me.txtR.Text)) And Trim(Me.txtR.Text) <> "" Then
MsgBox "请输入数字!"
End If
End Sub
Private Sub txtSum_KeyPress(KeyAscii As Integer)
'数量
If Not IsNumeric(Trim(Me.txtSum.Text)) And Trim(Me.txtSum.Text) <> "" Then
MsgBox "请输入数字!"
End If
End Sub
Private Sub txtValue_KeyPress(KeyAscii As Integer)
If Not IsNumeric(Trim(Me.txtValue.Text)) And Trim(Me.txtValue.Text) <> "" Then
MsgBox "请输入数字!"
End If
End Sub
Dim Sql As String
Dim msg As String
Dim RS As ADODB.Recordset
Private Sub cmdAdd_Click()
'添加
Dim i As Integer
If Trim(Me.txtNo.Text) <> "" And Trim(Me.txtSum.Text) <> "" Then
Sql = "select 商品编号,销售价 from 商品库存表 where 商品编号= " & Trim(Me.txtNo.Text)
Set RS = SelectSQL(Sql, msg)
If RS.EOF Then
MsgBox "库中无此商品!"
Else
For i = 1 To Me.ListView1.ListItems.Count
If Me.ListView1.ListItems(i).Text = Trim(Me.txtNo.Text) Then
MsgBox "列表中已有!"
Exit Sub
End If
Next i
Set ltmW = Me.ListView1.ListItems.Add
ltmW.Text = Trim(Me.txtNo.Text)
ltmW.ListSubItems.Add , , RS.Fields(0)
ltmW.ListSubItems.Add , , RS.Fields(3)
ltmW.ListSubItems.Add , , Trim(Me.txtSum.Text)
'ltmW.ListSubItems.Add , , RS.Fields(2)
Me.txtAllValue.Text = Val(Me.txtAllValue.Text) + Val(Trim(Me.txtSum.Text)) * RS.Fields(3)
Me.txtAllValue.Text = Format(Me.txtAllValue.Text, "#.##")
End If
RS.Close
Else
MsgBox "主键不能为空!"
End If
End Sub
Private Sub cmdAll_Click()
'结账数据入库
Dim i As Integer
For i = 1 To Me.ListView1.ListItems.Count
Sql = "insert into 销售单表 values(" & Me.ListView1.ListItems(i).Text
Sql = Sql & ",'" & Date
Sql = Sql & "'," & Me.ListView1.ListItems(i).ListSubItems(3).Text
Sql = Sql & ",'" & Time
Sql = Sql & "')"
' dbOperateW Sql
BatchSelectSQL Sql
Next i
Me.txtR.Text = Str((Val(Trim(Me.txtGive.Text)) - Val(Trim(Me.txtAllValue.Text))))
Me.txtR.Text = Format(Me.txtR.Text, "#.##")
MsgBox "操作成功!总金额为" & Trim(Me.txtAllValue.Text) & "元,应找金额为" & Me.txtR.Text & "元"
Me.txtNo.Text = ""
Me.txtSum.Text = ""
Me.txtValue.Text = ""
Me.txtAllValue.Text = ""
End Sub
Private Sub cmdDel_Click()
'删除
Dim i As Integer, bln As Boolean
If Trim(Me.txtNo.Text) <> "" Then
For i = 1 To Me.ListView1.ListItems.Count
If Me.ListView1.ListItems(i).Text = Trim(Me.txtNo.Text) Then
bln = True
Exit For
End If
Next i
If bln = True Then
Me.txtAllValue.Text = Val(Me.txtAllValue.Text) - Val(Me.ListView1.ListItems(i).ListSubItems(2)) * _
Val(Me.ListView1.ListItems(i).ListSubItems(3))
Me.txtAllValue.Text = Format(Me.txtAllValue.Text, "#.##")
Me.ListView1.ListItems.Remove (i)
Me.txtNo.Text = ""
Me.txtSum.Text = ""
Me.txtValue.Text = ""
Else
MsgBox "列表中没有!"
End If
Else
MsgBox "主键不能为空!"
End If
End Sub
Private Sub cmdExit_Click()
'退出操作
超市销售管理系统.Show
Unload Me
End Sub
Private Sub Form_Unload(Cancel As Integer)
'退出操作
超市销售管理系统.Enabled = True
Unload Me
End Sub
Private Sub cmdModify_Click()
'修改
Dim i As Integer, bln As Boolean
If Trim(Me.txtNo.Text) <> "" Then
For i = 1 To Me.ListView1.ListItems.Count
If Me.ListView1.ListItems(i).Text = Trim(Me.txtNo.Text) Then
bln = True
Exit For
End If
Next i
If bln = True Then
Me.txtAllValue.Text = Val(Me.txtAllValue.Text) + Val(Me.ListView1.ListItems(i).ListSubItems(2)) * _
(Val(Trim(txtSum.Text)) - Val(Me.ListView1.ListItems(i).ListSubItems(3)))
Me.txtAllValue.Text = Format(Me.txtAllValue.Text, "#.##")
Me.ListView1.ListItems(i).ListSubItems(3).Text = Trim(txtSum.Text)
Else
MsgBox "列表中没有!"
End If
Else
MsgBox "主键不能为空!"
End If
End Sub
Private Sub Command1_Click()
Me.ListView1.ListItems.Clear
End Sub
'Private Sub Form_Resize()
'控件大小的动态调整
'Dim i As Integer
'Me.ListView1.Width = Me.ScaleWidth
'For i = 1 To 5
' Me.ListView1.ColumnHeaders(i).Width = Me.ListView1.Width / 5
'Next i
'Me.ListView1.Top = 0
'Me.ListView1.Height = Me.ScaleHeight - Me.Picture1.Height
'Me.Picture1.Top = Me.ScaleHeight - Me.Picture1.Height
'Me.Picture1.Width = Me.ScaleWidth
'End Sub
Private Sub ListView1_ItemClick(ByVal Item As MSComctlLib.ListItem)
Me.txtNo.Text = Item.Text
Me.txtValue.Text = Item.ListSubItems(2).Text
Me.txtSum.Text = Item.ListSubItems(3).Text
End Sub
Private Sub txtGive_KeyPress(KeyAscii As Integer)
'实付金额
If Not IsNumeric(Trim(Me.txtGive.Text)) And Trim(Me.txtGive.Text) <> "" Then
MsgBox "请输入数字!"
End If
End Sub
Private Sub txtNo_KeyPress(KeyAscii As Integer)
'商品编号
If Not IsNumeric(Trim(Me.txtNo.Text)) And Trim(Me.txtNo.Text) <> "" Then
MsgBox "请输入数字!"
End If
End Sub
Private Sub txtR_KeyPress(KeyAscii As Integer)
'应找金额
If Not IsNumeric(Trim(Me.txtR.Text)) And Trim(Me.txtR.Text) <> "" Then
MsgBox "请输入数字!"
End If
End Sub
Private Sub txtSum_KeyPress(KeyAscii As Integer)
'数量
If Not IsNumeric(Trim(Me.txtSum.Text)) And Trim(Me.txtSum.Text) <> "" Then
MsgBox "请输入数字!"
End If
End Sub
Private Sub txtValue_KeyPress(KeyAscii As Integer)
If Not IsNumeric(Trim(Me.txtValue.Text)) And Trim(Me.txtValue.Text) <> "" Then
MsgBox "请输入数字!"
End If
End Sub