⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmoutadd.frm

📁 这个是基于vb的物资信息管理系统
💻 FRM
📖 第 1 页 / 共 2 页
字号:
            Text4.Text = ""
            Text4.SetFocus
            Exit Sub
        End If
    End If
    
    If MSFlexGrid1.Rows > 1 Then
        Myrs1.AddNew
        Myrs1.Fields("出库单号码") = Text1.Text
        Myrs1.Fields("发票号码") = Text2.Text
        Myrs1.Fields("出库类型") = Combo1.Text
        If Text3.Text = "" Then
            Myrs1.Fields("工程号") = Null
        Else
            Myrs1.Fields("工程号") = Text3.Text
        End If
        Myrs1.Fields("出库日期") = Text4.Text
        If Text5.Text = "" Then
            Myrs1.Fields("经办人") = Null
        Else
            Myrs1.Fields("经办人") = Text5.Text
        End If
        If Text6.Text = "" Then
            Myrs1.Fields("保管人") = Null
        Else
            Myrs1.Fields("保管人") = Text6.Text
        End If
        Myrs1.Update
        count = MSFlexGrid1.Rows
        For i = 1 To (count - 1)
            Myrs2.AddNew
            Myrs2.Fields("出库单号码") = Text1.Text
            Myrs2.Fields("材料编码") = MSFlexGrid1.TextMatrix(i, 0)
            Myrs2.Fields("数量") = Val(MSFlexGrid1.TextMatrix(i, 4))
            If MSFlexGrid1.TextMatrix(i, 5) = "" Then
                Myrs2.Fields("单价") = Null
            Else
                Myrs2.Fields("单价") = Val(MSFlexGrid1.TextMatrix(i, 5))
            End If
            Myrs2.Fields("金额") = Val(MSFlexGrid1.TextMatrix(i, 6))
            If MSFlexGrid1.TextMatrix(i, 7) = "" Then
                Myrs2.Fields("备注") = Null
            Else
                Myrs2.Fields("备注") = MSFlexGrid1.TextMatrix(i, 7)
            End If
            Myrs2.Update
            '更新余额库
            str = MSFlexGrid1.TextMatrix(i, 0)
            Num = MSFlexGrid1.TextMatrix(i, 4)
            price = MSFlexGrid1.TextMatrix(i, 6)
            SQLstring = "update msurplus set 数量=数量-" + CStr(Num) + ",金额=金额-" + CStr(price) + " where 材料编码='" & str & "'"
            Mydb.Execute (SQLstring)
            'Set mrc = mydb.OpenRecordset("select * from msurplus where 材料编码='" & str & "'")
            'If mrc.Fields("数量") = 0 Then
                'mrc.Delete
            'End If
            'mrc.Close
        Next i
        Unload Me
        Project.StatusBar1.Panels(2).Text = "就绪"
        Exit Sub
    Else
        MsgBox "出库单中必须至少包含一项材料明细。" & vbCrLf & "此出库单中未填写材料信息,请填写。", vbOKOnly + vbExclamation, "警告"
        Exit Sub
    End If
End Sub

Private Sub cmdAddRecord_Click()
    Project.StatusBar1.Panels(2).Text = "添加出库信息"
    OutInfo.Show 1
End Sub

Private Sub cmdCancel_Click()
    Text1.Text = ""
    Text2.Text = ""
    Text3.Text = ""
    Text4.Text = ""
    Text5.Text = ""
    Text6.Text = ""
    Combo1.ListIndex = 0
    Text1.SetFocus
End Sub

Private Sub cmdClose_Click()
    Myrs2.Close
    Myrs1.Close
    Mydb.Close
    Myws.Close
    Unload Me
    Project.StatusBar1.Panels(2).Text = "就绪"
End Sub

Private Sub cmdDelRecord_Click()
    Dim i As Integer, j As Integer
    
    Text7.Visible = False
    If MSFlexGrid1.Rows > 1 Then
        If MsgBox("确认要删除这条记录吗?", vbOKCancel + vbExclamation, "警告") = vbOK Then
            i = MSFlexGrid1.Row
            Text7.Text = MSFlexGrid1.TextMatrix(i, 0)
            Text7.Text = ""
            MSFlexGrid1.TextMatrix(i, 0) = Text7.Text
            Text7.Text = MSFlexGrid1.TextMatrix(i, 1)
            Text7.Text = ""
            MSFlexGrid1.TextMatrix(i, 1) = Text7.Text
            Text7.Text = MSFlexGrid1.TextMatrix(i, 2)
            Text7.Text = ""
            MSFlexGrid1.TextMatrix(i, 2) = Text7.Text
            Text7.Text = MSFlexGrid1.TextMatrix(i, 3)
            Text7.Text = ""
            MSFlexGrid1.TextMatrix(i, 3) = Text7.Text
            Text7.Text = MSFlexGrid1.TextMatrix(i, 4)
            Text7.Text = ""
            MSFlexGrid1.TextMatrix(i, 4) = Text7.Text
            Text7.Text = MSFlexGrid1.TextMatrix(i, 5)
            Text7.Text = ""
            MSFlexGrid1.TextMatrix(i, 5) = Text7.Text
            Text7.Text = MSFlexGrid1.TextMatrix(i, 6)
            Text7.Text = ""
            MSFlexGrid1.TextMatrix(i, 6) = Text7.Text
            Text7.Text = MSFlexGrid1.TextMatrix(i, 7)
            Text7.Text = ""
            MSFlexGrid1.TextMatrix(i, 7) = Text7.Text
            For j = i To (MSFlexGrid1.Rows - 2)
                MSFlexGrid1.TextMatrix(j, 0) = MSFlexGrid1.TextMatrix(j + 1, 0)
                MSFlexGrid1.TextMatrix(j, 1) = MSFlexGrid1.TextMatrix(j + 1, 1)
                MSFlexGrid1.TextMatrix(j, 2) = MSFlexGrid1.TextMatrix(j + 1, 2)
                MSFlexGrid1.TextMatrix(j, 3) = MSFlexGrid1.TextMatrix(j + 1, 3)
                MSFlexGrid1.TextMatrix(j, 4) = MSFlexGrid1.TextMatrix(j + 1, 4)
                MSFlexGrid1.TextMatrix(j, 5) = MSFlexGrid1.TextMatrix(j + 1, 5)
                MSFlexGrid1.TextMatrix(j, 6) = MSFlexGrid1.TextMatrix(j + 1, 6)
                MSFlexGrid1.TextMatrix(j, 7) = MSFlexGrid1.TextMatrix(j + 1, 7)
            Next j
            MSFlexGrid1.Rows = MSFlexGrid1.Rows - 1
            If MSFlexGrid1.Rows = 1 Then
                cmdDelRecord.Enabled = False
            End If
        End If
    End If
End Sub

Private Sub combo1_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = 13 Then
        Text3.SetFocus
    End If
End Sub

Private Sub Form_Activate()
    Project.StatusBar1.Panels(2).Text = "添加出库单"
End Sub

Private Sub Form_Load()
    MSFlexGrid1.Cols = 8
    MSFlexGrid1.Rows = 1
    MSFlexGrid1.Row = 0
    MSFlexGrid1.Col = 0
    MSFlexGrid1.Text = "材料编码"
    MSFlexGrid1.Col = 1
    MSFlexGrid1.Text = "材料名称"
    MSFlexGrid1.Col = 2
    MSFlexGrid1.Text = "规格型号"
    MSFlexGrid1.Col = 3
    MSFlexGrid1.Text = "计量单位"
    MSFlexGrid1.Col = 4
    MSFlexGrid1.Text = "数量"
    MSFlexGrid1.Col = 5
    MSFlexGrid1.Text = "单价"
    MSFlexGrid1.Col = 6
    MSFlexGrid1.Text = "金额"
    MSFlexGrid1.Col = 7
    MSFlexGrid1.Text = "备注"
    Text7.Visible = False
    Combo1.AddItem "修理"
    Combo1.AddItem "销售"
    Combo1.AddItem "改造"
    Combo1.AddItem "北拨"
    Combo1.AddItem "南拨"
    Combo1.ListIndex = 0
    cmdDelRecord.Enabled = False
    cmdCancel.Enabled = False
    Text4.Text = Date
    Set Myws = DBEngine.Workspaces(0)
    Set Mydb = Myws.OpenDatabase(App.Path + "\store.mdb")
    Set Myrs1 = Mydb.OpenRecordset("select * from outlib")
    Set Myrs2 = Mydb.OpenRecordset("select * from outlibdetail")
End Sub

Private Sub MSFlexGrid1_Click()
    Dim c As Integer
    Dim r As Integer
    
    With MSFlexGrid1
        c = .Col
        r = .Row
        Text7.Left = MSFlexGrid1.Left + MSFlexGrid1.ColPos(c)
        Text7.Top = MSFlexGrid1.Top + MSFlexGrid1.RowPos(r)
        If .Appearance = 1 Then
            Text7.Left = Text7.Left + 2 * Screen.TwipsPerPixelX
            Text7.Top = Text7.Top + 2 * Screen.TwipsPerPixelY
        End If
        Text7.Width = .ColWidth(c)
        Text7.Height = .RowHeight(r)
        Text7.Text = .Text
    End With
    Text7.Visible = True
    Text7.SetFocus
End Sub


Private Sub MSFlexGrid1_Scroll()
    Text7.Visible = False
End Sub

Private Sub Text1_Change()
    cmdCancel.Enabled = True
End Sub

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = 13 Then
        Text2.SetFocus
    End If
End Sub

Private Sub Text2_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = 13 Then
        Combo1.SetFocus
    End If
End Sub

Private Sub Text3_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = 13 Then
        Text4.SetFocus
    End If
End Sub

Private Sub Text4_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = 13 Then
        Text5.SetFocus
    End If
End Sub

Private Sub Text5_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = 13 Then
        Text6.SetFocus
    End If
End Sub

Private Sub Text6_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = 13 Then
        cmdAdd.SetFocus
    End If
End Sub

Private Sub Text7_Change()
    MSFlexGrid1.Text = Text7.Text
End Sub

Private Sub Text7_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyReturn Then
        Text7.Visible = False
    End If
End Sub

Private Sub Text7_LostFocus()
    Text7.Visible = False
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -