Private Sub Command1_Click()
Dim rsu As ADODB.Recordset
Set rsu = New ADODB.Recordset
Dim li As ListItems
If ListView1.ListItems.Count = 0 Then
MsgBox "Please insert a Ingredients.", vbInformation
ListView2.SetFocus
Exit Sub
End If
If Label1.Caption = "" Then
MsgBox "Please press click.", vbInformation
Command4.SetFocus
Exit Sub
End If
If Len(Combo1) = 0 Then
MsgBox "Please insert a Item", vbInformation
ListView2.SetFocus
Exit Sub
End If
rsu.Open "select * from madewith", DataEnvironment1.Connection1, 1, 3
X = Val(ListView1.ListItems(ListView1.SelectedItem.Index).SubItems(4))
W = Val(ListView1.ListItems(ListView1.SelectedItem.Index).SubItems(2))
Do Until ListView1.ListItems.Count = 0
rsu.MoveNext
rsu.Fields("itemid") = Label1.Caption
rsu.Fields("ingredientid") = W
rsu.Fields("quantity") = X
rsu.Update
rsu.MoveNext
ListView1.SetFocus
ListView1.ListItems.Remove ListView1.SelectedItem.Index
Loop
rsu.Close
MsgBox "Save!", vbInformation, "Recipe Setup"
Text1.Enabled = True
Text1.Text = ""
Combo1.ListIndex = -1
Combo1.Enabled = True
Combo1.SetFocus
Command1.Enabled = True
Command3.Enabled = True
Label1.Caption = ""
ListView1.ListItems.Clear
End Sub
Private Sub Command2_Click()
Text1.Enabled = True
Text1.Text = ""
Combo1.ListIndex = -1
Combo1.Enabled = True
Combo1.SetFocus
Command1.Enabled = True
Command3.Enabled = True
ListView1.ListItems.Clear
End Sub
Private Sub Command3_Click()
If ListView1.ListItems.Count = 0 Then
MsgBox "There is no Item(s) in the list.", vbInformation, "System Info"
Else
ListView1.ListItems.Remove ListView1.SelectedItem.Index
End If
End Sub
Private Sub Command4_Click()
Dim q As String
Dim rscustoms As New ADODB.Recordset
If Combo1.ListCount > 0 Or Combo1.Text > "" Then
q = Combo1.Text
rscustoms.Open "select * from items where name='" & q & "'", DataEnvironment1.Connection1, 1, 3
If rscustoms.RecordCount > 0 Then
Label1.Caption = rscustoms.Fields("itemid")
End If
End If
End Sub
Private Sub Command5_Click()
End Sub
Private Sub Form_Load()
Dim rs As New ADODB.Recordset
Dim r As New ADODB.Recordset
Dim s As New ADODB.Recordset
If DataEnvironment1.Connection1.State = adstateclose Then
DataEnvironment1.Connection1.Open
End If
rs.Open "select* from ingredients ", DataEnvironment1.Connection1, 1, 3
If rs.RecordCount > 0 Then
Do While Not rs.EOF
ListView2.ListItems.Add , , Val(Text)
ListView2.ListItems(ListView2.ListItems.Count).SubItems(1) = rs.Fields("name")
ListView2.ListItems(ListView2.ListItems.Count).SubItems(2) = rs.Fields("ingredientid")
rs.MoveNext
Loop
End If
End Sub
Private Sub Label3_Click()
End Sub
Private Sub ListView1_BeforeLabelEdit(Cancel As Integer)
Cancel = 1
End Sub
Private Sub ListView2_BeforeLabelEdit(Cancel As Integer)
Cancel = 1
End Sub
Private Sub ListView2_DblClick()
Dim li As ListItem
Dim X As String
Dim rsc As New ADODB.Recordset
Dim Y As String
If ListView2.ListItems.Count <> 0 Then
Y = ListView2.SelectedItem.Text
rsc.Open "select * from ingredients where name='" & Y & "'", DataEnvironment1.Connection1, 1, 3
If rsc.RecordCount > 0 Then
With ListView3.ListItems
lv = ListItem
Set lv = .Add(, , Val(Text2))
lv.SubItems(2) = rsc.Fields("ingredientid")
lv.SubItems(3) = ListView2.SelectedItem.Text
End With
End If
End If
If Text1.Text = "" Then
MsgBox "Please type the quantity!", vbExclamation, "System Info"
Text1 = ""
Text1.SetFocus
Else
With ListView1.ListItems
z = Text1.Text
Set li = .Add(, , Val(Text2))
li.SubItems(1) = ListView2.SelectedItem.SubItems(1)
li.SubItems(2) = z
li.SubItems(3) = ListView2.SelectedItem.Text
End With
Text1.Text = ""
Text1.SetFocus
End If
End Sub
Private Sub ListView2_KeyPress(KeyAscii As Integer)
Dim li As ListItem
If Text2.Text = "" Then
MsgBox "Please type the quantity!", vbExclamation, "System Info"
Text2.SetFocus
Else
With ListView1.ListItems
Set li = .Add(, , Val(Text1))
li.SubItems(1) = ListView2.SelectedItem.SubItems(1)
li.SubItems(3) = ListView2.SelectedItem.Text
End With
Text1.Text = ""
Text1.SetFocus
End If
End Sub
Private Sub ListView3_BeforeLabelEdit(Cancel As Integer)
Cancel = 1
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Command1.SetFocus
End If
If KeyAscii >= 48 And KeyAscii <= 57 Or KeyAscii = 8 And KeyAscii <> 46 Then
Chr (KeyAscii)
Else
KeyAscii = 0
End If
End Sub