fk_cailiao_caigouwenyuan.vb

来自「本软件设计为在"采购部""工程部""财务部""总经理"等部门之间的采购审核流转等」· VB 代码 · 共 1,424 行 · 第 1/4 页

VB
1,424 行
字号
        Me.Controls.Add(Me.Button2)
        Me.Controls.Add(Me.Button1)
        Me.Controls.Add(Me.TextBox17)
        Me.Controls.Add(Me.Label19)
        Me.Controls.Add(Me.TextBox16)
        Me.Controls.Add(Me.Label18)
        Me.Controls.Add(Me.TextBox15)
        Me.Controls.Add(Me.Label17)
        Me.Controls.Add(Me.TextBox14)
        Me.Controls.Add(Me.Label16)
        Me.Controls.Add(Me.TextBox12)
        Me.Controls.Add(Me.Label14)
        Me.Controls.Add(Me.TextBox11)
        Me.Controls.Add(Me.Label13)
        Me.Controls.Add(Me.TextBox10)
        Me.Controls.Add(Me.Label12)
        Me.Controls.Add(Me.Label11)
        Me.Controls.Add(Me.TextBox8)
        Me.Controls.Add(Me.Label10)
        Me.Controls.Add(Me.DateTimePicker2)
        Me.Controls.Add(Me.Label9)
        Me.Controls.Add(Me.TextBox6)
        Me.Controls.Add(Me.Label7)
        Me.Controls.Add(Me.TextBox5)
        Me.Controls.Add(Me.Label6)
        Me.Controls.Add(Me.Label5)
        Me.Controls.Add(Me.DateTimePicker1)
        Me.Controls.Add(Me.Label4)
        Me.Controls.Add(Me.GroupBox1)
        Me.Controls.Add(Me.GroupBox2)
        Me.Controls.Add(Me.GroupBox3)
        Me.Controls.Add(Me.GroupBox5)
        Me.Controls.Add(Me.Button4)
        Me.Controls.Add(Me.GroupBox4)
        Me.Controls.Add(Me.CheckBox1)
        Me.Controls.Add(Me.Button6)
        Me.Controls.Add(Me.ComboBox6)
        Me.Controls.Add(Me.GroupBox6)
        Me.MaximizeBox = False
        Me.Name = "Fk_cailiao_caigouwenyuan"
        Me.Text = "付款申请单-采购文员录入"
        Me.GroupBox1.ResumeLayout(False)
        Me.GroupBox2.ResumeLayout(False)
        Me.GroupBox3.ResumeLayout(False)
        CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

#End Region
    Dim intz As Decimal
    Dim intf As Decimal
    Dim int123 As Decimal
    Dim inty As Integer
    Dim yyy As Integer

    'load事件
    Private Sub Fk_cailiao_caigouwenyuan_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        xianshiyinhangxinxi() '显示所有银行的信息
        xianshihetongmingcheng() '显示所有存在的合同号
        xianshi_gongcheng_bianhao() '显示所有存在的工程编号
    End Sub

    '显示所有银行的信息
    Private Sub xianshiyinhangxinxi()
        Dim mydataset As New DataSet
        Dim i As Integer
        Dim y As Integer
        Dim mystr As String
        Dim str As String
        mystr = "select 银行名称 from bankInf"
        mydataset = GetDataFromDB(mystr)
        y = mydataset.Tables(0).Rows.Count
        For i = 0 To y - 1
            str = Trim(mydataset.Tables(0).Rows(i)("银行名称"))
            ComboBox1.Items.Add(str)
        Next
        mydataset.Dispose()
    End Sub

    '显示所有存在的合同编号
    Private Sub xianshihetongmingcheng()
        Dim mydataset As New DataSet
        Dim i As Integer
        Dim y As Integer
        Dim mystr As String
        Dim str As String
        mystr = "select 合同编号 from fk_hetong"
        mydataset = GetDataFromDB(mystr)
        y = mydataset.Tables(0).Rows.Count
        For i = 0 To y - 1
            str = Trim(mydataset.Tables(0).Rows(i)("合同编号"))
            ComboBox2.Items.Add(str)
        Next
        mydataset.Dispose()
    End Sub

    '显示所有存在的工程编号
    Private Sub xianshi_gongcheng_bianhao()
        Dim mydataset As New DataSet
        Dim i As Integer
        Dim y As Integer
        Dim mystr As String
        Dim str As String
        mystr = "select 工程编号 from technologyInf"
        mydataset = GetDataFromDB(mystr)
        y = mydataset.Tables(0).Rows.Count
        For i = 0 To y - 1
            str = Trim(mydataset.Tables(0).Rows(i)("工程编号"))
            ComboBox3.Items.Add(str)
        Next
        mydataset.Dispose()
    End Sub


    '保存付款申请单
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If Me.TextBox1.Text.Trim = "" Then
            MsgBox("请输入付款申请单编号!", MsgBoxStyle.Information, "提示!")
            Me.TextBox1.Text = Nothing
            Exit Sub
        End If
        Dim mystr As String
        Dim mystr1 As String = Me.TextBox1.Text.Trim
        mystr = "select * from fk_cailiao_shenqingdan where 申请单编号 =" + Chr(39) + mystr1 + Chr(39)
        If panduan(mystr) = True Then
            MsgBox("该付款申请单编号已经存在!", MsgBoxStyle.Information, "提示!")
            TextBox1.Text = Nothing
            TextBox1.Focus()
            Exit Sub
        End If
        Dim sssstr As String
        If CheckBox1.Checked = True Then
            sssstr = ComboBox6.Text.Trim
        Else
            sssstr = "预付款"
        End If

        Dim sqlstr As String
        sqlstr = "INSERT INTO fk_cailiao_shenqingdan " & _
        "(申请单编号,收货单编号,订购单编号,工程名称,工程编号,发文日期,付款内容,付款日期,收款单位名称,开户银行,银行帐号,付款依据,付款方式,付款说明,合同金额,已付金额,本次申请金额,余额,录入时间,采购文员) " & _
        "VALUES ('" & Me.TextBox1.Text.Trim & "','" & sssstr.Trim & "','" & Me.ComboBox2.Text.Trim & "','" & Me.TextBox5.Text.Trim & "','" & Me.ComboBox3.Text.Trim & "','" & Me.DateTimePicker1.Value.Date & "','" & Me.TextBox6.Text.Trim & "','" & Me.DateTimePicker2.Value.Date & "','" & Me.TextBox8.Text.Trim & "','" & Me.ComboBox1.Text.Trim & "','" & Me.TextBox10.Text.Trim & "','" & Me.TextBox11.Text.Trim & "','" & Me.TextBox12.Text.Trim & "','" & Me.TextBox2.Text.Trim & "','" & Me.TextBox14.Text.Trim & "','" & Me.TextBox15.Text.Trim & "','" & Me.TextBox16.Text.Trim & "','" & Me.TextBox17.Text.Trim & "','" & Now.Date & "','" & UserName & "')"

        If UpdateData(sqlstr) = False Then
            MsgBox("没有成功添加了该付款申请信息信息!", MsgBoxStyle.OKOnly + _
                    MsgBoxStyle.Exclamation, "添加成功")
            Exit Sub
        Else
            MsgBox("已经成功添加了该付款申请信息!", MsgBoxStyle.OKOnly + _
                    MsgBoxStyle.Exclamation, "添加成功")
            Button1.Enabled = False
        End If


    End Sub

    '当工程编号,改变时候,显示工程的名称
    Private Sub ComboBox3_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox3.SelectedIndexChanged
        Dim str As String = Me.ComboBox3.Text.Trim
        Dim mystr As String
        Dim mydataset As DataSet
        mystr = "select 工程名称 from technologyInf where 工程编号 =" + Chr(39) + str + Chr(39)
        mydataset = GetDataFromDB(mystr)
        TextBox5.Text = Trim(mydataset.Tables(0).Rows(0)("工程名称"))
        mydataset.Dispose()

    End Sub


    '本次付款金额值的填写
    Private Sub TextBox16_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox16.TextChanged
        If CheckBox2.Checked = False Then
            Exit Sub
        End If

        If TextBox16.Text = "" Then
            Exit Sub
        End If

        If yyy <> 0 Then
            If TextBox14.Text.Trim = "" Then
                MsgBox("请输入--应付款--值!", MsgBoxStyle.Information, "提示")
                Exit Sub
            End If

            If TextBox15.Text.Trim = "" Then
                MsgBox("请输入--应付款--值!", MsgBoxStyle.Information, "提示")
                Exit Sub
            End If
        Else
            yyy = yyy + 1
            Exit Sub
        End If

        If TextBox16.Text.Trim = "" Then
            TextBox17.Text = ""
            Exit Sub
        End If
        Dim str1 As String = TextBox16.Text.Trim
        Dim y As Integer = str1.Length
        Dim sstr As String
        Dim i As Integer
        Dim yy As Integer = 0
        For i = 1 To y
            sstr = Microsoft.VisualBasic.Mid(str1, i, 1)
            If sstr = "0" Or sstr = "1" Or sstr = "2" Or sstr = "3" Or sstr = "4" Or sstr = "5" Or sstr = "6" Or sstr = "7" Or sstr = "8" Or sstr = "9" Or sstr = "." Then
                If sstr = "." Then
                    yy = yy + 1
                    If yy = 2 Then
                        MsgBox("已经有了--.--,不能再输入了!", MsgBoxStyle.Information, "提示")
                        TextBox16.Focus()
                        Exit Sub
                    End If
                End If
            Else
                MsgBox("请输入正确的数字,特别要分清----。----和---.----", MsgBoxStyle.Information, "提示")
                TextBox1.Focus()
                Exit Sub
            End If
        Next
        Dim str2 As String = TextBox14.Text.Trim
        Dim int1 As Decimal
        Dim int2 As Decimal
        Dim int3 As Decimal

        Dim int As Decimal
        int1 = Convert.ToDecimal(str2) '总额
        int2 = Convert.ToDecimal(str1) '本次付款额
        int3 = Convert.ToDecimal(TextBox15.Text.Trim) '已经付款总额

        int = int1 - int2 - int3
        TextBox17.Text = int.ToString
        int = int2 / int1
        int = int * 100
        TextBox7.Text = int.ToString + "%"


    End Sub


    '判断输入的数字是否正确
    Private Sub TextBox14_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox14.TextChanged
        If CheckBox2.Checked = False Then
            Exit Sub
        End If


        Dim str1 As String = TextBox14.Text.Trim
        Dim y As Integer = str1.Length
        Dim sstr As String
        Dim i As Integer
        Dim yy As Integer = 0
        For i = 1 To y
            sstr = Microsoft.VisualBasic.Mid(str1, i, 1)
            If sstr = "0" Or sstr = "1" Or sstr = "2" Or sstr = "3" Or sstr = "4" Or sstr = "5" Or sstr = "6" Or sstr = "7" Or sstr = "8" Or sstr = "9" Or sstr = "." Then
                If sstr = "." Then
                    yy = yy + 1
                    If yy = 2 Then
                        MsgBox("已经有了--.--,不能再输入了!", MsgBoxStyle.Information, "提示")
                        TextBox1.Focus()
                        Exit Sub
                    End If
                End If
            Else
                MsgBox("请输入正确的数字,特别要分清----。----和---.----", MsgBoxStyle.Information, "提示")
                TextBox14.Focus()
                Exit Sub
            End If
        Next

        If inty = 0 Then
            inty = inty + 1
            Exit Sub
        Else
            intz = Convert.ToDecimal(str1)
            If intz <> 0 Then
                int123 = intf / intz

                TextBox4.Text = int123.ToString + "%"
            Else
                TextBox4.Text = "0%"
            End If
        End If
    End Sub


    '从订购单号得到合同金额
    Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
        If CheckBox2.Checked = False Then
            Exit Sub
        End If
        TextBox1.Text = "fk_" + ComboBox2.Text.Trim
        Dim str, mystr As String
        '得到已付款的总金额
        str = "select sum(本次申请金额) from fk_cailiao_shenqingdan as " + "已付金额" + " where 订购单编号 = " + Chr(39) + ComboBox2.Text.Trim + Chr(39) + " and 标志 = " + Chr(39) + "4" + Chr(39)

        '得到合同金额
        mystr = "select sum(供应商金额) from dinggou_cailiao_baojiadan where 采购单编号 = " + Chr(39) + ComboBox2.Text.Trim + Chr(39) + " and 供应商名称 = ( select 选择的供应商名称 from dinggou_zongbiao where 采购单编号 = " + Chr(39) + ComboBox2.Text.Trim + Chr(39) + ")"

        Dim mydataset As New DataSet
        mydataset = GetDataFromDB(str)
        Dim y As Integer = mydataset.Tables(0).Rows.Count

        If mydataset.Tables(0).Rows(0).Item(0) Is System.DBNull.Value Then
            TextBox15.Text = "0"
        Else
            Dim str2 As String = Trim(mydataset.Tables(0).Rows(0).Item(0))
            TextBox15.Text = str2
            intf = Convert.ToDecimal(str2)
        End If


        mydataset = GetDataFromDB(mystr)
        If mydataset.Tables(0).Rows(0).Item(0) Is System.DBNull.Value Then
            TextBox14.Text = "0"
            MsgBox("合同不存在,或者系统有问题,请与系统设计人员联系!", MsgBoxStyle.Information, "提示")
            Exit Sub
        Else
            TextBox14.Text = Trim(mydataset.Tables(0).Rows(0).Item(0))

        End If
        mydataset.Dispose()


    End Sub



    Private Sub TextBox17_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox17.TextChanged
        If CheckBox2.Checked = False Then
            Exit Sub
        End If

        Dim str As String = TextBox17.Text.Trim
        If str = "" Then
            Exit Sub
        ElseIf Convert.ToDecimal(str) < 0 Then
            MsgBox("请注意你的付款已经超过应付款拉!", MsgBoxStyle.Information, "提示")
            Exit Sub
        End If

        Dim str2 As String = TextBox14.Text.Trim
        If str2 = "" Then
            str2 = "0"
            Exit Sub
        End If

        Dim int1 As Decimal
        Dim int2 As Decimal
        Dim int3 As Decimal

        Dim int As Decimal
        int1 = Convert.ToDecimal(str2) '总额

        int3 = Convert.ToDecimal(TextBox17.Text.Trim) '剩下金额

⌨️ 快捷键说明

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