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

📄 frminadd.frm

📁 一个简单实用的物资信息管理系统。很简单
💻 FRM
📖 第 1 页 / 共 2 页
字号:
        If Text4.Text = "" Then
            Myrs1.Fields("经办人") = Null
        Else
            Myrs1.Fields("经办人") = Text4.Text
        End If
        If Text5.Text = "" Then
            Myrs1.Fields("保管人") = Null
        Else
            Myrs1.Fields("保管人") = Text5.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
            SQLstring = "select * from msurplus where 材料编码='" & MSFlexGrid1.TextMatrix(i, 0) & "'"
            Set mrc = Mydb.OpenRecordset(SQLstring)
            '如果材料余额表中没有当前材料编码的记录,就添加
            If mrc.EOF = True Then
                mrc.Close
                SQLstring = "select * from msurplus"
                Set mrcc = Mydb.OpenRecordset(SQLstring)
                mrcc.AddNew
                mrcc.Fields("材料编码") = MSFlexGrid1.TextMatrix(i, 0)
                mrcc.Fields("数量") = 0
                If MSFlexGrid1.TextMatrix(i, 5) = "" Then
                    mrcc.Fields("单价") = Null
                Else
                    mrcc.Fields("单价") = MSFlexGrid1.TextMatrix(i, 5)
                End If
                mrcc.Fields("金额") = 0
                mrcc.Fields("备注") = Null
                mrcc.Update
                mrcc.Close
            Else
                mrc.Close
            End If
            Num = Val(MSFlexGrid1.TextMatrix(i, 4))
            price = Val(MSFlexGrid1.TextMatrix(i, 6))
            SQLstring = "update msurplus set 数量=数量+" + CStr(Num) + ",金额=金额+" + CStr(price) + " where 材料编码='" & MSFlexGrid1.TextMatrix(i, 0) & "'"
            Mydb.Execute (SQLstring)
        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 = "添加进库信息"
    Info.Show 1
    
End Sub

Private Sub cmdCancel_Click()
    Text1.Text = ""
    Text2.Text = ""
    Text3.Text = ""
    Text4.Text = ""
    Text5.Text = ""
    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
    
    Text6.Visible = False
    If MSFlexGrid1.Rows > 1 Then
        If MsgBox("确认要删除这条记录吗?", vbOKCancel + vbExclamation, "警告") = vbOK Then
            i = MSFlexGrid1.Row
            Text6.Text = MSFlexGrid1.TextMatrix(i, 0)
            Text6.Text = ""
            MSFlexGrid1.TextMatrix(i, 0) = Text6.Text
            Text6.Text = MSFlexGrid1.TextMatrix(i, 1)
            Text6.Text = ""
            MSFlexGrid1.TextMatrix(i, 1) = Text6.Text
            Text6.Text = MSFlexGrid1.TextMatrix(i, 2)
            Text6.Text = ""
            MSFlexGrid1.TextMatrix(i, 2) = Text6.Text
            Text6.Text = MSFlexGrid1.TextMatrix(i, 3)
            Text6.Text = ""
            MSFlexGrid1.TextMatrix(i, 3) = Text6.Text
            Text6.Text = MSFlexGrid1.TextMatrix(i, 4)
            Text6.Text = ""
            MSFlexGrid1.TextMatrix(i, 4) = Text6.Text
            Text6.Text = MSFlexGrid1.TextMatrix(i, 5)
            Text6.Text = ""
            MSFlexGrid1.TextMatrix(i, 5) = Text6.Text
            Text6.Text = MSFlexGrid1.TextMatrix(i, 6)
            Text6.Text = ""
            MSFlexGrid1.TextMatrix(i, 6) = Text6.Text
            Text6.Text = MSFlexGrid1.TextMatrix(i, 7)
            Text6.Text = ""
            MSFlexGrid1.TextMatrix(i, 7) = Text6.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 cmdEditRecord_Click()
    Dim c As Integer
    Dim r As Integer
    
    c = 1
    r = 1
    Text6.Left = MSFlexGrid1.Left + MSFlexGrid1.ColPos(c)
    Text6.Top = MSFlexGrid1.Top + MSFlexGrid1.RowPos(r)
    If MSFlexGrid1.Appearance = 1 Then
        Text6.Left = Text6.Left + 2 * Screen.TwipsPerPixelX
        Text6.Top = Text6.Top + 2 * Screen.TwipsPerPixelY
    End If
    Text6.Width = MSFlexGrid1.ColWidth(c)
    Text6.Height = MSFlexGrid1.RowHeight(r)
    Text6.Visible = True
    Text6.SetFocus
    Text6.Text = MSFlexGrid1.Text
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 = "备注"
    Text6.Visible = False
    cmdDelRecord.Enabled = False
    cmdCancel.Enabled = False
    Text3.Text = Date
    Set Myws = DBEngine.Workspaces(0)
    Set Mydb = Myws.OpenDatabase(App.Path + "\store.mdb")
    Set Myrs1 = Mydb.OpenRecordset("select * from inlib")
    Set Myrs2 = Mydb.OpenRecordset("select * from inlibdetail")
End Sub

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


Private Sub MSFlexGrid1_Scroll()
    Text6.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
        Text3.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
        cmdAdd.SetFocus
    End If
End Sub

Private Sub Text6_Change()
    MSFlexGrid1.Text = Text6.Text
End Sub

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

Private Sub Text6_LostFocus()
    Text6.Visible = False
End Sub



⌨️ 快捷键说明

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