?? frmsell1.frm
字號:
If Index = 0 Then
txtSQL = "select * from customers where CompanyName = '" & Trim(cboItem(0)) & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If Not mrc.EOF Then
For intCount = 1 To 2
cboItem(intCount).Clear
Next intCount
cboItem(1).AddItem mrc!ContactName
cboItem(2).AddItem mrc!Phone
cusText = mrc!CustomerID
For intCount = 1 To 2
cboItem(intCount).ListIndex = 0
Next intCount
End If
mrc.Close
ElseIf Index = 3 Then
txtSQL = "select * from products where ProductName= '" & Trim(cboItem(3)) & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If Not mrc.EOF Then
For intCount = 4 To 5
cboItem(intCount).Clear
cboItem(intCount).AddItem mrc.Fields(intCount - 2)
cboItem(intCount).ListIndex = 0
Next intCount
proText = mrc!ProductID
End If
mrc.Close
End If
End If
End Sub
Private Sub cboItem_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
EnterToTab KeyCode
End Sub
Private Sub cmdExit_Click()
If mblChange And cmdSave.Enabled Then
If MsgBox("保存當前記錄的變化嗎?", vbOKCancel + vbExclamation, "警告") = vbOK Then
'保存
Call cmdSave_Click
End If
End If
Unload Me
End Sub
Private Sub cmdSave_Click()
Dim intCount As Integer
Dim sMeg As String
Dim mrc As ADODB.Recordset
Dim MsgText As String
For intCount = 0 To 3
If Trim(txtItem(intCount) & " ") = "" Then
Select Case intCount
Case 0
sMeg = "商品數量"
Case 1
sMeg = "商品單價"
Case 2
sMeg = "銷售日期"
Case 3
sMeg = "折 扣"
End Select
sMeg = sMeg & "不能為空!"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
txtItem(intCount).SetFocus
Exit Sub
End If
Next intCount
If Trim(cboItem(0)) = "" Then
MsgBox "請選擇顧客名稱!", vbOKOnly + vbExclamation, "警告"
cboItem(0).SetFocus
Exit Sub
End If
If Trim(cboItem(3)) = "" Then
MsgBox "請選擇商品名稱!", vbOKOnly + vbExclamation, "警告"
cboItem(3).SetFocus
Exit Sub
End If
For intCount = 0 To 1
If Not IsNumeric(Trim(txtItem(intCount) & " ")) Then
Select Case intCount
Case 0
sMeg = "商品數量"
Case 1
sMeg = "商品單價"
Case 3
sMeg = "折 扣"
End Select
sMeg = sMeg & "請輸入數字!"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
txtItem(intCount).SetFocus
Exit Sub
End If
Next intCount
If Not IsDate(Trim(txtItem(2))) Then
MsgBox "請輸入日期!", vbOKOnly + vbExclamation, "警告"
txtItem(2).SetFocus
Exit Sub
End If
If gintOmode = 2 Then
'先刪除已有記錄
txtSQL = "delete from orders where OrderID ='" & Trim(txtNo) & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
End If
'再加入新記錄
txtSQL = "select * from orders"
Set mrc = ExecuteSQL(txtSQL, MsgText)
mrc.AddNew
mrc.Fields(0) = txtNo
mrc.Fields(1) = cusText
mrc.Fields(2) = cboItem(0)
mrc.Fields(3) = proText
mrc.Fields(4) = cboItem(3)
For intCount = 5 To 6
mrc.Fields(intCount) = Trim(cboItem(intCount - 1))
Next intCount
For intCount = 0 To 4
mrc.Fields(intCount + 7) = Trim(txtItem(intCount))
Next intCount
mrc.Update
mrc.Close
If gintOmode = 1 Then
For intCount = 0 To 4
txtItem(intCount) = ""
Next intCount
mblChange = False
MsgBox "添加銷售信息成功!", vbOKOnly + vbExclamation, "添加進貨信息"
Unload Me
If flagOedit Then
Unload frmSell
frmSell.txtSQL = "select * from orders"
frmSell.Show
End If
ElseIf gintOmode = 2 Then
Unload Me
If flagOedit Then
Unload frmSell
End If
frmSell.txtSQL = "select * from orders"
frmSell.Show
End If
End Sub
Private Sub Form_Load()
Dim sSql As String
Dim intCount As Integer
Dim MsgText As String
Dim mrcc As ADODB.Recordset
If gintOmode = 1 Then
Me.Caption = Me.Caption & "添加"
txtNo = GetRkno()
txtSQL = "select distinct CompanyName from customers"
Set mrcc = ExecuteSQL(txtSQL, MsgText)
If Not mrcc.EOF Then
cboItem(0).Clear
Do While Not mrcc.EOF
cboItem(0).AddItem mrcc.Fields(0)
mrcc.MoveNext
Loop
Else
MsgBox "請先設置顧客信息!", vbOKOnly + vbExclamation, "警告"
Exit Sub
End If
mrcc.Close
txtSQL = "select distinct ProductName from products"
Set mrcc = ExecuteSQL(txtSQL, MsgText)
If Not mrcc.EOF Then
cboItem(3).Clear
Do While Not mrcc.EOF
cboItem(3).AddItem mrcc.Fields(0)
mrcc.MoveNext
Loop
Else
MsgBox "請先設置商品信息!", vbOKOnly + vbExclamation, "警告"
Exit Sub
End If
mrcc.Close
ElseIf gintOmode = 2 Then
Set mrcc = ExecuteSQL(txtSQL, MsgText)
If mrcc.EOF = False Then
With mrcc
txtNo = .Fields(0)
cusText = .Fields(1)
cboItem(0).Clear
cboItem(0).AddItem .Fields(2)
cboItem(0).ListIndex = 0
proText = .Fields(3)
For intCount = 3 To 5
cboItem(intCount).Clear
cboItem(intCount).AddItem .Fields(intCount + 1)
cboItem(intCount).ListIndex = 0
Next intCount
For intCount = 0 To 4
If Not IsNull(.Fields(intCount + 7)) Then
txtItem(intCount) = .Fields(intCount + 7)
End If
Next intCount
End With
End If
mrcc.Close
txtSQL = "select ContactName,Phone from customers where CustomerID = '" & Trim(cusText) & "'"
Set mrcc = ExecuteSQL(txtSQL, MsgText)
If Not mrcc.EOF Then
For intCount = 1 To 2
cboItem(intCount).Clear
cboItem(intCount).AddItem mrcc.Fields(intCount - 1)
cboItem(intCount).ListIndex = 0
Next intCount
End If
mrcc.Close
Me.Caption = Me.Caption & "修改"
End If
mblChange = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
gintOmode = 0
End Sub
Private Sub txtItem_Change(Index As Integer)
'有變化設置gblchange
mblChange = True
End Sub
Private Sub txtItem_GotFocus(Index As Integer)
txtItem(Index).SelStart = 0
txtItem(Index).SelLength = Len(txtItem(Index))
End Sub
Private Sub txtItem_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
EnterToTab KeyCode
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -