Private Sub Grid_KeyUp(KeyCode As Integer, Shift As Integer)
Dim Rst As ADODB.Recordset
Dim Cmd As ADODB.Command
Dim SQL As String
Dim I As Integer
Dim N As Integer
Select Case KeyCode
Case vbKeyReturn
If Grid.Rows <= 1 Then Exit Sub
Dim K As Boolean
K = Foot(lblSum.Caption, lblsums.Caption)
If K = False Then Exit Sub
Conn.BeginTrans
Set Cmd = New ADODB.Command
Cmd.ActiveConnection = Conn
Call ReSet
Number = Number + 1
lbl.Caption = Format(Date$, "yymmdd") & "#" & Format(CStr(Number), "0000")
Case vbKeyF3
Call ReSet
Case vbKeyF4
If Grid.Rows = 1 Then Exit Sub
txtNum.Top = Grid.Top + Grid.RowHeight(Grid.RowSel) * Grid.RowSel + 5
txtNum.Visible = True
txtNum.SetFocus
txtNum.Text = Grid.TextMatrix(Grid.RowSel, 7)
txtNum.SelStart = 0
txtNum.SelLength = Len(txtNum.Text)
Grid.Enabled = False
Case vbKeyF5
If Grid.Rows = 1 Then Exit Sub
txtZK.Top = Grid.Top + Grid.RowHeight(Grid.RowSel) * Grid.RowSel + 5
txtZK.Visible = True
txtZK.SetFocus
txtZK.Text = Grid.TextMatrix(Grid.RowSel, 8)
txtZK.SelStart = 0
txtZK.SelLength = Len(txtZK.Text)
Grid.Enabled = False
Case vbKeyF6
fra.Visible = True
Grid.Enabled = False
txtTM.SetFocus
Case vbKeyF7
''单位
If Grid.Rows = 1 Then Exit Sub
Set Rst = New ADODB.Recordset
SQL = "select unit from yaopin_unit where id='" & Grid.TextMatrix(Grid.RowSel, 1) & "'"
Rst.Open SQL, Conn, adOpenStatic, adLockReadOnly, adCmdText
If Rst.EOF Then Exit Sub
cobUnit.Clear
For I = 1 To Rst.RecordCount
cobUnit.AddItem Rst.Fields(0)
Rst.MoveNext
Next
Set Rst = Nothing
cobUnit.Top = Grid.Top + Grid.RowHeight(Grid.RowSel) * Grid.RowSel + 5
cobUnit.Visible = True
cobUnit.SetFocus
Grid.Enabled = False
Case vbKeyF8
If Grid.Rows = 1 Then Exit Sub
txtZ.Enabled = True
txtZ.SelStart = 0
txtZ.SelLength = Len(txtZ.Text)
txtZ.SetFocus
Grid.Enabled = False
Case vbKeyF9
If Grid.Rows > 1 Then Exit Sub
frmBack.Show 1
Case vbKeyDelete, vbKeyBack
Dim SumCash As Currency
If Grid.RowSel = 0 Then Exit Sub
If Grid.Rows = 2 Then ReSet: Exit Sub
IDList.Remove Grid.RowSel
Grid.RemoveItem Grid.RowSel
For I = 1 To Grid.Rows - 1
SumCash = SumCash + Val(Grid.TextMatrix(I, 10))
Next
lblSum.Caption = Format(CStr(SumCash), ".00")
lblsums.Caption = Format(CStr(SumCash) * IIf(Val(txtZ.Text) = 1, 1, Val(txtZ.Text) / 10), ".00")
For I = 1 To Grid.Rows - 1
Grid.TextMatrix(I, 0) = CStr(I)
Next
End Select
End Sub
Private Sub tmr_Timer()
Dim I As Integer
tmr.Enabled = False
If Id = "" Then Exit Sub
For I = 1 To IDList.Count
If Id = IDList(I) Then
Grid.TextMatrix(I, 7) = CStr(Val(Grid.TextMatrix(I, 7)) + 1)
Grid.TextMatrix(I, 10) = Format(CStr(Val(Grid.TextMatrix(I, 7)) * Grid.TextMatrix(I, 9)), ".00")
GoTo ee
End If
Next
Dim Rst As ADODB.Recordset
Dim CRst As ADODB.Recordset
Dim SQL As String
Dim SumCash As Currency
SQL = "select id,name,guige,changjia,unit,price from v_yaopin_list where tiaoma='" & Id & "' order by switch desc"
Set Rst = New ADODB.Recordset
Rst.CursorLocation = adUseClient
Rst.Open SQL, Conn, adOpenStatic, adLockReadOnly, adCmdText
If Rst.EOF Then Id = "": Exit Sub
SQL = "select * from yaopin_cost where id='" & Rst.Fields("id") & "'"
Set CRst = New ADODB.Recordset
CRst.CursorLocation = adUseClient
CRst.Open SQL, Conn, adOpenDynamic, adLockReadOnly, adCmdText
If CRst.EOF Then Exit Sub
Set CRst = Nothing